How to Redirect 404 Pages to Homepage in WordPress?

As an internet user, you may have encountered 404 error pages many times. It is a common error caused when you change the permalink of your website without changing the links pointing at the original URL. 

Many web owners too, neglect this error thinking it to be totally normal and does not create a negative impact on their website. However, if you are serious about the growth and development of the website, the 404 errors should not be avoided. It can drive away your potential customers from your website and can also impact the SEO by damaging the backlink of your website. Therefore, not fixing this issue can be a huge mistake. 

In this article, we will discuss what a 404 error is, why you should redirect 404 pages, and how to redirect 404 pages to the homepage on the WordPress website. 

What is a 404 Error?

A 404 error is a common HTTP error which indicates that the server was unable to find the requested website. It is essentially telling you that the web page you are trying to find does not exist. 

The 404 pages can be displayed in different ways. 404 Error, 404 Not Found, Error 404 Not Found, 404 Page Not Found, etc are some of the common ways.

Causes of 404 Page Error:

404 Page Error is caused when 

  • You change the permalink of your website without changing the link point of the original URL
  • You move the website from one host to another
  • The domain name is mistyped
  • The server responsible for the website is not running or the connection is broken
  • You have not added 301 redirects
  • The domain name you entered does not exist
  • The requested domain name cannot be converted to an IP by the Domain Name System (DNS)

Impact Caused by 404 Error Page

The most obvious impact caused by 404 error pages is they can drive the visitors away from your website. It is very common as nobody is going to stay on a website if they think the site does not have what they are looking for. This will affect the bounce rate of your website as the visitor will instantly exit your site after viewing one page. It is a serious problem since the bounce rate is an important metric of SEO.

How to Redirect 404 Pages to Homepage?

One of the easiest ways to fix the 404-page issue is by directing them to the homepage. It will allow your visitors to renavigate your website and look for the content that he/she is looking for.

Here, we will show you how it can be done in 2 different ways i.e. 

i) Using a WordPress Plugin

ii) Writing a Custom Code

i) Using a WordPress plugin

This method is quite easy to redirect the 404 pages to the homepage as you won’t have to write any codes. It is advisable to use a plugin if you want to avoid making adverse mistakes when you try doing so by writing the codes. 

There are a number of plugins that will redirect the 404 error page to your homepage. Here, we are going to use All 404 Redirect to Homepage plugin to show you how it is done. 

Redirect 404 Pages to Homepage

With that being said, let’s get the tutorial started:

The first thing you need to do is install and activate All 404 Redirect to Homepage plugin on your WordPress website. 

To install the plugin, download a copy of All 404 Redirect to Homepage from WordPress.org. Then, upload it on your WordPress website. 

Once the plugin is uploaded, click on the “Activate” button for activation.

Upon activation, go to Settings > All 404 Redirect to the Homepage settings page. 

Then, set the 404 Redirection Status to Enabled.

Redirect 404 Pages to Homepage

Now click on the Update Options button to update your changes.

You can check out the redirected URL from the 404 URL tab.

Redirect 404 Pages to Homepage

ii) Writing a Custom Code

If you do not want to use a WordPress plugin to redirect the homepage, you can do that by writing code. 

To do that, you need to login to your WordPress dashboard. Then, navigate to Appearance > Theme Editor

Now look for a file called 404.php or create one if it does not exist one. Then, copy the following code;

<?php  
header("HTTP/1.1 301 Moved Permanently");   
header("Location: ".get_bloginfo('url'));   
exit();   
?>

Now, click on Save changes. All your 404 page will then redirect to the homepage.