How to show homepage for 404 errors
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:



{% 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:

{% include "index" with {
    entry: craft.entries.section('homepage').one()
} %}


(replace .one() with .first() if this is for Craft 2.)