WordPress 404 Redirect to Homepage Without Plugin

Wordpress 404 Redirect to Homepage Without PluginBefore i post the code for better WordPress 404 redirect to homepage, i just make it sure that you shouldn’t use any plugin, because it is easy just to put three lines of codes to your 404.php page of your wordpress theme. The reason why plugin is not needed, because if there is too many plugins, it will makes the bad performance for your website.

WordPress 404 Redirect to Homepage

For some reasons, search engine may index your 404 error pages, and that’s the bad point for your websites. Below are the code to put in your 404.php which you can find it on your wordpress theme. If you don’t know where, just login to your wordpress site, got to Apperarance >> Editor. Find the 404.php and put below codes above the header code.
First find the header code in 404.php below:

get_header();

Then change it like this:

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

The code above is so simple, and now every error page is redirected to your homepage. Oh, just implement the codes above to make it works.

Topics: 404, code, page, php, plugin, redirect, SEO, without, wordpress


Leave a Reply

© 2011 e-WWW. All rights reserved.
Proudly designed by Andhie.