How to Redirect 404 Error Page to Homepage in WordPress: A Beginner’s Guide

I think most internet users have experienced a 404 Error at one point in their lives or another. It is a pretty common one after all. While it can be a mild annoyance for the visitors, it can be quite a serious issue for the website owners. The obvious solution here is to fix the links on your site and stop it from happening of course. However, these errors can still occur even when the website owner is being vigilant. In that case, you can instead redirect the error page to the other parts of your site in order to help retain your visitors. In this short article, we are going to show you how to redirect 404 error page to homepage in WordPress. Before we get into that, let us try and understand what 404 errors are and why it can be harmful to your site.
What is a 404 Error Page and Why Redirect It?
A 404 Error is pretty simple to explain actually. A 404 is an HTTP error which indicates that the server was unable to find the requested website. It is essentially telling you that the web page you’re trying to find doesn’t exist. It can be shown in different ways, 404 Error, 404 Not Found, Error 404 Not Found, 404 Page Not Found, and so forth.
The obvious downside to 404 errors is that seeing it can drive the visitor away from your website entirely. Nobody is going to stay on a website if they think the site doesn’t have what they’re looking for. This affects your bounce rate, which is the rate at which visitors navigate away from the website after viewing one page. It can be a serious problem since the Bounce Rate is an important metric of Search Engine Optimization (SEO).
So, an easy way to avoid that is to ensure that the 404 Error Page redirects back to the homepage. In this article, we are going to show you two easy ways of doing so.
How to Redirect 404 Error Page to Homepage in WordPress
1. Using a Plugin
It is very easy to redirect 404 to homepage in WordPress using a WordPress redirect plugin. For this, you are going to need the All 404 Redirect to Homepage Plugin. Firstly, you will need to install and activate the plugin. If you aren’t sure how to do that, check out our article on how to install WordPress plugins.
Once the plugin has been installed and activated, it will automatically start working. Use your Admin Sidebar to go to Settings>>All 404 Redirect to Homepage and you can either disable the plugin or set where it redirects. Click on Update Options if you’ve made any changes.
2. Without using a Plugin
If you wanted to know how to redirect 404 error page to homepage in WordPress without having to install a plugin then we have you covered. First of all, access your WordPress site through a File Manager or FTP. For more information on using FTP, you can check out our WordPress FTP guide. Once you are in, navigate to public_html>>wp-content>>themes and look for your active theme.
Once you find it, open the folder and search for 404.php. If you find it, we advise you to create a backup of the file before proceeding. Once you’re done, right click on it and click on Edit.
Now all you need to do is make sure that this file contains only the following code.
<?php
header(
"HTTP/1.1 301 Moved Permanently"
);
header(
"Location: "
.get_bloginfo(
'url'
));
exit
();
?>
Paste it onto the file and save your changes.
If you can’t find the file, you can just create one yourself. Once you do, simply open and paste the aforementioned code afterward.
Now instead of seeing a 404 error page, your visitors will instead be redirected to your homepage.
To Conclude
Now you should know how to redirect 404 error page to homepage in WordPress. It is very easy to do, with or without using a plugin and can affect how your visitors experience your website. If you want to improve the Bounce Rate and SEO score of your website even further, you can check out our article on how to display random posts in WordPress. Similarly, adding WordPress Charts to liven up your website can go a long way to help retain your visitors. We hope you found this short guide to be helpful. If you have any comments please let us know in the comment section below.
If you want more informative articles about WordPress, you can check out our other articles.
- How To Hide WordPress Login Page From Hackers and Spammers?
- WordPress Pages Vs Posts – What’s the Difference?
- How to Create a Website from scratch using WordPress Page Builders!