How to Redirect your 404 page to the Home Page in WordPress

How to Redirect your 404 page to the Home Page in WordPress (Beginner’s Guide)

Are you willing to redirect your Error 404 page to your home page in WordPress?

When Redirecting your Error 404 not found pages to your website’s home page, it can help reduce bounce rate and give your users a chance to discover other useful content on your website.

So we will show you step by step guide to redirect your error 404 page to your home page in WordPress.

Why you need to Redirect Your 404 Page to Your WordPress Home Page?

Contents

  • Users can locate your website when typing a related keyword into their search engine. However they will be disappointed when they only find a 404 page. To keep traffic, you can redirect to the homepage.
  • If your website has too many 404 errors, it’s best to redirect users to the homepage and there provide them with an explanation. To check this, look for crawl errors in our Google Webmaster Tools account.
  • By forgetting to change the URL of an old blog post that received a new title, users will get a 404 message and nobody will ever reread the article
  • Inactive PPC ads that are supposed to direct to a landing page, will trigger more 404 pages than is good for business

How to redirect all 404 Pages to Home Page in WordPress

Use RankMath to Set up Custom 404 page Redirects in WordPress

RankMath SEO for WordPress is one of the best WordPress SEO plugin that allows you to easily optimize your WordPress website for search engines and social media platforms. To explain better, Rank Math is a Search Engine Optimization plugin for WordPress that makes it easy for anyone to optimize their content with built-in suggestions based on widely-accepted best practices.

Their Redirects feature track all 404 page errors and lets you set up smart 404 page redirects in WordPress.

First thing you need to do is install and activate RankMath. For more details, see our step by step guide on how to install a WordPress plugin.

Once the plugin is activated, you need to enabled the 404 Monitor module by navigating to WordPress Dashboard > Rank Math > Dashboard > Modules.

enabled the 404 Monitor module

Start by going to the 404 monitor using the WordPress menu.
Depending on your website, you would see some errors or a blank slate. Here is how our 404 monitor looks like.If you remember, this is how the Advanced 404 Monitor looks like.

404 monitor


Regardless of the type of 404 monitor you use, you will be able to resolve the 404 errors on your website.

There are only 3 ways to resolve a 404 error.

  • Fix the source of the problem
  • Redirect the problematic URL
  • Ignore the problem
Redirect All 404 Pages to Home Page in WordPress Using Code Snippet

This method uses a simple code snippet to redirect all 404 pages to homepage. In this method, you need to add code to your WordPress files.
First, you’ll 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, then you’ll need to edit that file instead.

To edit this file, you need to connect to your WordPress hosting account with an FTP client or their file manager tool.
Once you’re connected to your website, you will be able to see your 404.php file in your WordPress themes folder.

ftp-404-php-file

You need to add the following code as the first line in your 404.php file:

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

Next, you need to save the 404.php file and re upload it to your theme directory using FTP or your hosting control panel.

Now, when a page is not found, instead of showing a 404 page, they will be redirected to your WordPress home page.

Remember, generally you don’t want to redirect your 404 page to your home page forever. It’s a great temporary solution, until you create a custom 404 page that will convert better or simply redirect users to a more relevant page.

If you have any issue on how to redirect error 404, you can use our comment box or get to us through our Facebook page, we would reply you soonest.

Share this Post

3 thoughts on “How to Redirect your 404 page to the Home Page in WordPress (Beginner’s Guide)”

  1. Well, describe the article on 404 error to redirect on the home page, the best part of Rank Math plugin suggestion. The writing is very clear & it makes anyone understand easily. Thanks for the wonderful writing.

  2. Does anyone know if the code works as well for multisite installations?

    If so, does the 404 page bounce to the subdomain / subfolder / subsite or the main or root domain / folder / site?

Leave a Comment

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

Scroll to Top
Scroll to Top