How to Redirect 404 Error Page to Home Page in WordPress

How to Redirect 404 Error Page to Home Page in WordPress

Do you want to make your WordPress site’s 404 error not found page redirect to the home page?

When you remove a page from your website and a visitor accesses it using that URL, they will receive a 404 Not Found error.

A 404 page has a significant impact on your site’s search ranking and bounce rate.

So it’s a good idea to redirect 404 pages to another related page. However, due to a shortage of time, some websites reroute users to the home page. The 404 error page should be redirected to a more relevant website.

This will have no effect on your site’s ranking or bounce rate.

In this article, I’ll show you how to use WordPress to redirect the 404 Error Not Found page to the home page.

How to Redirect a 404 Error Not Found Page in WordPress to the Home Page

Here are two options for redirecting the 404 Error Not Found page in your WordPress site to the main page:
by utilising a plugin or utilising custom code.

How to Use Code to Redirect a 404 Page to the Home Page

Using custom code on your site, you may redirect all 404 pages to the homepage. All you have to do now is paste the code into your WordPress file.

To get started, create a new file called 404.php in your WordPress theme folder. You’ll need to change the 404.php file if your theme currently has one.

After that, in your 404.php file, add the following code:

<?php

header("HTTP/1.1 301 Moved Permanently");

header("Location: ".get_bloginfo('url'));

exit();

?>

Save your 404.php file after that. When a visitor comes to your site’s 404 pages, he or she will now be forwarded to the main page.

How to Use a Plugin to Redirect a 404 Page to the Home Page

You can use a plugin if you don’t want to contribute code to your site. Install and activate the Redirection plugin on your website first.

After you’ve activated the plugin, go to Tools >> Redirection and follow the steps in the screenshot below.

How to Redirect 404 Error Page to Home Page in WordPress

In the Source URL area, type your 404 Error Page, and in the Target URL field, type your Home Page URL. After that, just leave the rest of the options alone.

After you’ve entered your URL, click “Add redirect.” To test it, go to the URL that says “404 not found.”

When a visitor arrives at that 404 not found page, he will be instantly forwarded to your site’s home page.

Tip: It may take a long time to load if your site has a lot of 404 Error Not Found pages.

Final thought

If a user encounters a 404 error on your website, it is advisable to direct them to the home page. However, if your site has a lot of 404 error pages and you redirect them to the main page, your search ranking may suffer.

Furthermore, forwarding the 404 Error Not Found page to the homepage instead of the related page is akin to deceiving Google.

Only redirect the 404 error page to content that is more relevant. So that your site’s ranking and reputation are unaffected.

Thanks for reading this How to Redirect 404 Error Page to Home Page in WordPress guide! any suggestion or anything wants to tell or ask to us share in the comment section and Bookmark our Blog2Boss to get interesting stuff.

Leave a Comment

Your email address will not be published. Required fields are marked *