How to redirect 404 page to the home page in WordPress?

When a user attempts to access a broken or dead link or a link which doesn’t exist, WordPress redirect such requests to special page called “404.php”. However some bloggers prefer to redirect all 404 errors to home page. If you are one of them, Here is an easy way to do this,

Useful Read: How to put your WordPress website in maintenance mode without a plugin

1. Go to your theme’s folder.

2. Open your 404.php file, if it doesn’t exist, then create one.

3. Delete all the code and text inside that file.

4. And paste the following code in that file and save it.

//Redirect 404 page to the home page
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".home_url());



  1. I can’t deny that you haven’t written informative article.

    It is true that your article is very much helpful and informative.

    As I had started my blog few months ago so I haven’t enough information about 404 error pages and that’s why, I had so many 404 errors on my blog and after reading this article, I get to know that how to deal with these not found errors.

    If I am right then 404 pages are those where we don’t find any content except a 404 error message and It occurs If any writer deleted the existing content and the URL of that content remain indexed in search results.

    I also heard that Google don’t like these pages so every webmaster should check out their website regularly for these errors to keep their website SEO friendly.

    Thanks for sharing this article with us because It taught me that how I can handle these pages and keep my site at safer side. 😀


Leave a Comment.