How to redirect all 404 error page to homepage start

2 minute read
How to redirect all 404 error page to homepage start

Some people like to redirect all 404 error pages to homepage or any page like a start page that contains categories and something related to the 404 error pages, this will automatically fix all 404 errors seen in Google web master tools panel and also any new 404 error page, you have to use the seo 301 redirect to tell search engines that the page is removed permanently.

I did not test if this will affect you site seo or not, but what I know is that when you have a 404 error page, you can handle it by using 301 redirect to another page, this will transfer the page rank of the 404 page to the new page.

Anyway to do this function, you have two options as the following:

1- Copy the following code and go to your theme and edit it using theme editor in WordPress control panel, choose the file 404.php which is the 404 error template, past the code in the top of the file, before any code just after “<?php” and delete cach if you have a cach plugin installed.

header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: “.get_bloginfo(‘url’));

2- Install the plugin “All 404 Redirect to Homepage” to your site from plugins page, search the wordpress plugins directory and install it, it an awesome and simple plugin and will do the job.

I recommend to use the second options and install the plugin, this because in the first option, if you changed the theme, you have to put the code for the new 404.php file and so on, but when using the plugin it not affected when changing any thing.

× Shopping Cart

Your cart is empty.