Wordpress Redirect 404

June 17, 2009 in Wordpress How To | Comments (0)

If you make changes to your wordpress blog, and get 404 errors you can redirect all of them to your homepage so your visitors never see a 404 error. Simply put this code into the 404.php file under Appearance > Editor > 404 Template


<?php

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

exit();

?>

You wouldn’t want to simply drop all of your traffic and pages and redirect it to your site becuase when you get indexed again, you’ll get penaliized for duplicate content!

if you have an emergency, or only a few pages on a new site this is a simple way to fix the 404 error in Wordpress.