Do you want to redirect the 404 error not found page to the home page in your WordPress site?
When you delete a page from your website and when the visitor visits your website through that URL, then they have to face a 404 Not Found error. A 404 page greatly affects your site’s search ranking and bounce rate. So redirecting 404 pages to another related page is a good idea. But some websites redirect the user to the home page due to lack of time.
But in my opinion, you should redirect the 404 error page to more relevant content. This will not affect the ranking and bounce rate of your site.
In this article, I will tell you how to redirect the 404 Error Not Found page to the home page in WordPress.
How to Redirect 404 Error Not Found Page to Home Page in WordPress
Here I will tell you about two methods that will help you to redirect the 404 Error Not Found page to the home page in your WordPress site:
- Using simple Plugin
- Using code changes
How to Redirect 404 Page to Home Page Using Code
You can redirect all 404 pages to the homepage by using custom code on your site. Simply, you need to add the code to your WordPress file.
First, you need to create a new file in your WordPress theme folder and name it 404.php. If your theme already has a 404.php file, you’ll need to edit the file.
And then you need to add the following code to your 404.php file:
<?php
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: “.get_bloginfo(‘url’));
exit();
?>
After this save your 404.php file. Now, when a visitor visits the 404 pages of your site, he/she will be redirected to the home page.
How to Redirect 404 Page to Home Page Using Plugin
If you are afraid to add code to your site, you can use a plugin.
First of all install and activate the Redirection plugin on your site. After activating the plugin, click on Tools >> Redirection and follow the below screenshot.
Here you add your 404 Error Page in the Source URL field and add the Home Page URL in the Target URL field. After that leave the rest of the settings as default.
After adding your URL click on “Add redirect”. Now to test it, you can click on the URL with 404 not found.
Now when a visitor visits that 404 not found page, he will automatically be redirected to the home page of your site.
Note: If your site has a lot of 404 Error Not Found pages, it may take you a long time.
Verdict
If your website has 404 errors, it is best to redirect the user to the home page. But if you have a lot of 404 error pages on your site and you redirect them to the home page, it can lower your search ranking. Also, redirecting the 404 Error Not Found page to the homepage by not redirecting to the related page is like cheating Google. Redirect the 404 error page to more relevant content only. So that there is no impact on your site’s ranking and reputation.