Redirect Error 404 page to homepage automatcially

wordpress

There are times when we remove pages from our website due to some reason, and later when some visitor comes to that page, he gets an Error 404 page. Without even giving a second look at your site, he quits to Google or some other search engine.

There is a way to redirect users from the error 404 homepage to your site’s main page. It requires you to place a PHP code within your site’s root folder. I have tested the code with WordPress, and it works fine.

Below is the code to redirect 404 errors to your homepage. Copy the code and paste it in the 404.php file which can be found in your Themes folder.

Remove everything that is written in that file and replace it with the below code.

<?php
header(“Status: 301 Moved Permanently”);
header(“Location:http://www.abc.com”);
?>

Make sure that you replace “http://www.abc.com” with your domain name.

RELATED POSTS: 

  1. Redirect URL using .htaccess
  2. How to remove URLs from Google Search or Google Cache via Google Webmasters?
  3. How to see NoFollow links on any webpage?
  4. How to create a good Robots.txt file?
Stay in touch with us on Facebook or Twitter or Google+ to keep yourself updated on stuff related to the world of Technology.