Redirect 404 pages to the homepage in WordPress

When users attempt to access a broken or dead link or a link that sends them to page that has been moved or deleted, WordPress redirects the request to a page called 404.php. This is not only frustrating for the user who is very likely to turn back and leave but it also gives a signal to Google who “sees” these errors and counts them in on the overall site evaluation and ranking.

In order to salvage some of the SEO juice of those pages, people prefer to redirect all these 404 errors to the home page and here’s a simple way to do this: Go to the theme’s folder. Open the 404.php file (if it doesn’t exist, create a blank one). Delete the code and text inside the file and paste the following code:

<?php
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: “.get_bloginfo(‘url’));
exit();
?>

If you don’t want to mess with the code or you don’t have access to it, simply install the following plugin: All 404 Redirect to Homepage (if you have a cache plugin installed, clear the cache to get the results reflected immediately). Although the plugin hasn’t been updated for over 2 years it still works in WordPress 4.0.

Do you want to build a flawless WordPress site? 

Related Blogs

Web developer
Symfony-PHP-Developer_02
Quick question?