normally with a 404 error the site will be redirected to theme/404.php. I'd like to the home page instead. I tried

ErrorDocument 404 http://www.example.com

but it doesn't work. How can I solve this issue?

  • A redirection with a 404 status code doesn't exist. Also, the file 404.php from a WordPress theme is the template loaded for requests that return a 404 status, no redirection to 404.php file occurs. I think you are confused about what HTTP status codes are and the difference with redirections.
    – cybmeta
    Oct 8, 2015 at 13:03

1 Answer 1


A 404 should never be a redirect. A redirection status begins with 3, not with 4.

You can either include the index.php (or home.php or front-page.php) in your 404.php or just remove the 404.php from your theme. Then WordPress will use the index.php.

  • It's false that removing the 404.php file will show the index.php. Have you tried it? Oct 8, 2015 at 12:36
  • @DanielMuñozParsapoormoghadam See the link in my answer: When no 404.php has been found, index.php is used.
    – fuxia
    Oct 8, 2015 at 12:39
  • Do you really understand the code you are linking there? Because below of if (is_404() && $template = get_404_template()): there is a fantastic elseif calling the get_search_template() function, which will return you a 404 error, again, since it's not finding the string you are supposedly searching. And yes, I tried it. Oct 8, 2015 at 12:52
  • @DanielMuñozParsapoormoghadam you are totally wrong. See the link in the answer again and study the code carefully.
    – cybmeta
    Oct 8, 2015 at 13:11
  • @DanielMuñozParsapoormoghadam The elseif matches only on search pages. This is never true on a 404 page. Quite the opposite: a search without matches results in a 404.
    – fuxia
    Oct 8, 2015 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.