Answers.Body: <p><code>404</code> isn’t a valid redirect status code, which is why <code>{% redirect '/' 404 %}</code> isn’t working correctly.</p>
  
  <p>It sounds like you want to:</p>
  
  <ul>
  <li>first issue a 301 or 302 redirect to the homepage</li>
  <li>then serve the homepage, but with a 404 status</li>
  </ul>
  
  <p>If I’m understanding you correctly, even if you could pull it off (maybe doable with a query string or something stored on the session), that would be bad for a couple reasons:</p>
  
  <ul>
  <li>the actual not-found resource is returning the wrong status code (301/302 instead of 404)</li>
  <li>now the homepage (a valid resource) is also returning the wrong status code (404 instead of 200)</li>
  </ul>
  
  <p>The biggest issue is the 2nd one, as it would have devastating SEO consequences. Any time Google hits a missing resource and is redirected back to the homepage, it will start remembering that your homepage doesn’t exist.</p>
  
  <p>A better solution would be to keep the URL pointed at the missing resource (so no redirect response), but to just render your homepage via the 404 template.</p>
  
  <p>That should be as simple as creating a <code>404.html</code> template with this:</p>
  
  
  
  <pre class="lang-twig prettyprint-override"><code>{% include "index" %}
  </code></pre>
  
  <p>(or whatever your actual homepage template is called.)</p>
  
  <p>If you have a Homepage Single section, you may need to pass that in as well:</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% include "index" with {
      entry: craft.entries.section('homepage').one()
  } %}
  </code></pre>
  
  <p>(replace <code>.one()</code> with <code>.first()</code> if this is for Craft 2.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-18T15:49:41.380Z
Answers.Text: Perfect! Many thanks for the quick response Brandon and for explaining so clearly.
Answers.UserDisplayName: Janine
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-18T20:46:31.803Z
Answers.Text: Just to add to what Brandon wrote, you can do more than just 404 templates, too. More here: [Handling Errors Gracefully in Craft CMS](https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms)
Answers.UserDisplayName: andrew.welch
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-18T14:33:33.543Z
Answers.LastActivityDate: 2018-04-18T14:33:33.543Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Instead of a standard 404 error page, I want to send 404s to the homepage and can't seem to get this working right.</p>
  
  <p>If I add <code>{% redirect '/' %}</code> in my 404.html template, that works except it gives a 302 found code instead of a 404.</p>
  
  <p>If I change it to <code>{% redirect '/' 404 %}</code> I get the correct 404 code but just a white screen instead of the homepage.</p>
  
  <p>I've also tried adding <code>ErrorDocument 404 /</code> to the .htaccess file, but that doesn't take effect as I think the Craft 404 mechanism overrides that.</p>
  
  <p>Can anyone help? Thanks. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-18T13:50:41.600Z
Comments.Text: How about https://craftcms.stackexchange.com/questions/5242/404-page-redirect-to-homepage ?
Comments.UserDisplayName: Steven Grant
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-18T14:07:29.027Z
Comments.Text: Thanks Steven. I had seen that, but the client would prefer to just go direct to the homepage. I suppose I could try a meta refresh after 0, but I remember they could cause SEO issues back in the day, so was hoping there was a cleaner way & I was just missing something?
Comments.UserDisplayName: Janine
Tags: <redirect><404><404-page>
Title: How to show homepage for 404 errors
ThreadText: # How to show homepage for 404 errors
  
  (Asked by: username_0 on 2018-04-18)
  
  Instead of a standard 404 error page, I want to send 404s to the homepage and can't seem to get this working right.
  
  If I add `{% redirect '/' %}` in my 404.html template, that works except it gives a 302 found code instead of a 404.
  
  If I change it to `{% redirect '/' 404 %}` I get the correct 404 code but just a white screen instead of the homepage.
  
  I've also tried adding `ErrorDocument 404 /` to the .htaccess file, but that doesn't take effect as I think the Craft 404 mechanism overrides that.
  
  Can anyone help? Thanks.
  
  **Tags:** redirect, 404, 404-page
  
  > **Comments:**
  > **username_1**: How about https://craftcms.stackexchange.com/questions/5242/404-page-redirect-to-homepage ?  
  > **username_0**: Thanks username_1. I had seen that, but the client would prefer to just go direct to the homepage. I suppose I could try a meta refresh after 0, but I remember they could cause SEO issues back in the day, so was hoping there was a cleaner way & I was just missing something?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-04-18. Score: 4 | Accepted answer
  
  `404` isn’t a valid redirect status code, which is why `{% redirect '/' 404 %}` isn’t working correctly.
  
  It sounds like you want to:
  
  * first issue a 301 or 302 redirect to the homepage
  * then serve the homepage, but with a 404 status
  
  If I’m understanding you correctly, even if you could pull it off (maybe doable with a query string or something stored on the session), that would be bad for a couple reasons:
  
  * the actual not-found resource is returning the wrong status code (301/302 instead of 404)
  * now the homepage (a valid resource) is also returning the wrong status code (404 instead of 200)
  
  The biggest issue is the 2nd one, as it would have devastating SEO consequences. Any time Google hits a missing resource and is redirected back to the homepage, it will start remembering that your homepage doesn’t exist.
  
  A better solution would be to keep the URL pointed at the missing resource (so no redirect response), but to just render your homepage via the 404 template.
  
  That should be as simple as creating a `404.html` template with this:
  
  ```twig
  {% include "index" %}
  
  ```
  
  (or whatever your actual homepage template is called.)
  
  If you have a Homepage Single section, you may need to pass that in as well:
  
  ```twig
  {% include "index" with {
      entry: craft.entries.section('homepage').one()
  } %}
  
  ```
  
  (replace `.one()` with `.first()` if this is for Craft 2.)
  
  > **Comments:**
  > **username_0**: Perfect! Many thanks for the quick response username_2 and for explaining so clearly.  
  > **username_3**: Just to add to what username_2 wrote, you can do more than just 404 templates, too. More here: [Handling Errors Gracefully in Craft CMS](https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms)  
  
  ---
  
  