One of the most annoying things when navigating a website is to click on a link and be faced with a “404 Page Not Found” page, or maybe you click on a link in Google search results and get the same error message.
This is a very simple problem to fix if you are running a WordPress Site, it involves editing one file and that is it. It should take about 30 seconds if you know what you are doing.
Once complete if anyone visits a page on your WordPress Site that no longer exists they will be forwarded back to your homepage automatically.
How to setup the Smart WordPress 404 Redirect:
Edit the following file:
wp-content/themes/YOUR-THEME/404.php
Delete everything in the file and paste the following:
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
?>
That’s it, you can test it by typing in a URL for your site that you know does not exist. It should forward you straight back to your homepage.
How simple is that! Any problems or questions please post them below.
Related posts:
How to Beat WordPress Comment Spam