You might be occasionally come to an error page called 404 which is also known as Page Not Found. A 404 page is an error page which explain site visitors that the page they are looking for not found on the website.

If you are having many 404 error page on your website then you may want to redirect all of them to your Word Press home page.  It will remove all 404 links from search engine index and transfer all benefits those links have to home page. So, it’s a good idea to get SEO benefit from not exist pages. If you are having lots of 404 error pages showing in google webmaster tool then this is the most recommended thing you can do quickly to resolve the issue.

WordPress theme support 404 template which is automatically called when 404 error occurs.  All you need to create 404.php file with following content and then upload to current active theme directory. If you already have 404.php in theme folder then overwrite old file with new file or add following content on top of existing file.

header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));

All you have done. Test it with a dummy 4o4 url to make sure code is working.


Written by Bala Krishna

Bala Krishna is web developer and occasional blogger from Bhopal, MP, India. He like to share idea, issue he face while working with the code.

This article has 4 comments

  1. louisg

    Thank you Bala Krishna, that’s very nice. Thanks for the SEO plug as well, gotta update everything when I get a chance.
    Have a great weekend!