How to Redirect 404 Page to Homepage in WordPress

If you are running a WordPress website, your user may encounter a 404 page. And you might be concerned about this; it’s understandable that you would worry since it can have a negative impact on your business/website if many users abandon due to encountering a 404 page.

This can be a legitimate explanation for an increase in your website bounce rate, as well as the loss of possible backlinks owing to these 404 pages. This is not a good scenario; the user will not like the experience, and SEO will be harmed. So, in plain language, you risk a lot of your traffic if you have a website with these 404 pages.

Now, you’d be wondering how to keep visitors from leaving your site, right? and you would probably be thinking of how to redirect your 404 page to your home page. Well, redirecting 404 pages to your home page is a great idea.

This way, if somebody encounters a 404 page on your site, they will be directed back to what is considered as the most relevant/important webpage of your website, which ultimately brings them closer to their intended destination.

Now, the next consideration is what you should do to redirect your 404 page to the homepage

However, in this guide, you will learn what is 404 page and How to Redirect 404 Page to Homepage in WordPress, why it is important for all WordPress users, and whether this approach of redirection is recommended? Or are there any other better options than redirecting 404 pages to the home page?

Let’s start by learning more about what a 404 error is and why it occurs.

What is a 404 Error, and Why Does It Happen?

A 404 error is one of the most common problems you’ll encounter while surfing the Web.

The Hypertext Transfer Protocol (HTTP) response code 404 indicates that the browser was unable to receive the information requested by the user, despite its capability to communicate with the server.

In plain words, The 404 error is a web page on your site that does not exist or has been moved. This can happen if you move, delete or rename any file within the directory of your website.

Google claims that the presence of a 404 error has no negative influence on your search rankings. However, if you don’t want to lose site traffic, it’s still worth fixing it.

That said, we’ll show you three methods to redirect your 404 pages to your home page.

How to Redirect A 404 Page To Your Homepage

I’ll show you three methods to redirect your 404 pages to your home page

  • Redirecting 404 page to a specific page or home page using a plugin
  • Redirecting All 404 page to home page using a plugin
  • Redirecting All 404 page to home page with custom code

Method 1) Redirecting 404 page to a specific page or home page using a plugin

This is the most effective approach to redirecting a 404 page to the homepage or any other specified page since no code will be required. It’s best to utilize a plugin to prevent errors when you try and do it yourself by writing code.

The most popular plugin that redirects the 404 page to the home page or to a new location is the Redirection plugin.

redirection plugin for wordpress

It’s important to tackle the relevant 404 pages one by one since they can be redirected appropriately. For blogs, portfolios, and other more specialized material, handling each of them individually is preferable so that they may be relocated where appropriate.

Users will need to direct to a new location if you relocate your blog article, and the same goes for outdated and damaged URLs.

So with the help of this plugin, you can redirect them to a specified or desired URL

After installing and activating this plugin go to :

  • Tools > Redirection > Add new redirection
  • In the Source URL box, type or paste the broken/old/altered URL
  • In the Target URL box, type or paste the new URL
  • Opt for URL and referrer in the match dropdown
  • In the Action box, chose Redirect to URL
  • Click on Add Redirection
redirection plugin settings

If there are a large number of pages on your website displaying the 404 error, it’s best to send them all to your homepage.

Method 2) Redirect All 404 Pages to Home Page in WordPress Using Plugin

So to redirect all 404 pages to the homepage then we can use the All 404 Redirect to Homepage plugin

redirect 404 page to homepage plugin in wordpress

This redirection plugin that I’m going to show you is unlike any other WordPress plugin. Instead of manually creating redirects for individual URLs, this plugin allows you to redirect all 404 URLs to your home page. This means that, rather than displaying the standard 404 error page to visitors who come across a broken link on your site, they will be redirected to the homepage

After installing and activating the plugin go to Settings > All 404 Redirect to the homepage. Now, set the 404 Redirection Status to Enabled.

And enter the URL of your homepage in the Redirect all 404 pages to input area.To save the changes, click on the update changes button.

all 404 redirect to home page plugin settings

Now that you’ve saved the changes, it’s time to check your website to ensure the plugin is functioning correctly.

You can check the site by entering a wrong URL at the end of your website URL (e.g., www.yourwebsite.com/dummytext) and then hit Enter.

If it takes you to your website’s home page, it is functioning correctly.

If you are an expert WordPress developer and know how to code, then you might want an alternative way to redirect the 404 pages to the homepage using custom code

How to Redirect 404 Page to Homepage in WordPress

Method 3) Redirect All 404 Pages to Home Page in WordPress with code

To redirect all 404 pages to the homepage with custom code, add a little piece of code in WordPress files.

404.php file in cpanel file manager

To begin, you’ll need to create a new file in your WordPress theme’s folder and name it 404.php. If there is already a 404.php file in your WordPress theme, you should modify it instead.

Now that the file has been generated, add this code at the top.

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

When you’re done, click the Save button. Website visitors will be redirected to the homepage if a 404 error occurs.

You may Like :

How to Disable WordPress Admin Toolbar

How To Check if User is Logged In WordPress

How to Check if User is Admin in WordPress

Advantages of Redirecting 404 Pages to your Homepage

  • If your website has too many 404 errors, you should redirect visitors to the homepage and give them an explanation. Examine Google Webmaster Tools for crawl issues on your website.
  • When Users types a related keyword into search engine, your site will come up. They will be disappointed, though, when they only discover a 404 page after searching. To keep visitors coming back, you can redirect URL to the homepage.
  • Users will get a 404 message when you forget to modify the URL of an old blog post with a new title, and no one will ever read it again.

Disadvantages of WordPress 404 Redirect to Homepage

  • Changing all URLs to our homepage might be inconvenient for visitors if they are looking for a certain page and get redirected to the homepage.
  • Redirecting all 404s does not benefit huge websites. The server would have to handle an infinite number of redirects, and the website would become unusable.
  • A large number of 404 redirects will damage our site’s overall search ranking. However, to Google, redirecting non-existing URLs to our homepage appears to be cheating.

FAQ(How to Redirect 404 Page to Homepage in WordPress)

Should you redirect 404 to Homepage?

A URL redirect may be required when a website is damaged (or destroyed), but it should not always be done. A worldwide redirect to the homepage is not recommended. Only send a category or parent page if providing the most relevant user experience possible would be beneficial. It’s fine to give out a 404 when the page isn’t available any longer.

How do I redirect a 404 error page to the home page in an HTML website?

Add this line in your .htaccess file.

ErrorDocument 404 http://website.com 

However, it’s not advised to send 404 not found pages to the homepage. This will cause crawlers to index your non-existent files and directories, which might be detrimental to your SEO.

Does Google crawl 404 page?

Google Remembers 404 Pages. Although Google may delete a web page from its index, if the page was previously live, it will remember that the URL formerly existed and will crawl that old URL to see whether it returned.

Wrapping up

I hope this article has provided you with valuable information on how to redirect 404 pages to the homepage in WordPress. If you have any questions or thoughts about the topic mentioned above, please share them via the comments section below!

Leave a Comment