HomeTechnologyTech SolutionHow to redirect your 404 page to the homepage in WordPress


Want to redirect your 404 page to your homepage in WordPress?

Redirecting the 404 “Not Found” page to your website’s homepage can help reduce your bounce rate and give your users the opportunity to discover other useful content on your website.

In this article, we will show you how to redirect your 404 page to your homepage in WordPress.

How to redirect your 404 page to the homepage in WordPress

Why should you redirect your 404 page to your WordPress homepage?

If a user tries to visit a page that doesn’t exist on your WordPress site, WordPress will show them a 404 error page instead.

The wording and appearance of this page may vary depending on the theme you are using.

Default WordPress 404 page

Most users who land on the standard 404 page quickly leave your site. This can increase your overall bounce rate and negatively impact your search engine rankings.

That’s why you should take the time to create a custom 404 page. Until you do that, however, you can use the shortcut in this tutorial and redirect users to the home page.

In a perfect world, you would also redirect certain 404 error requests to the most relevant pages.

Now let’s look at how to redirect all 404 errors to your homepage. We’ll cover two methods and also show you how to create custom redirects for individual pages:

Method 1: Redirect all 404 errors to the homepage in WordPress

For this method we use All-in-One SEO for WordPress (AIOSEO). It’s the best WordPress SEO plugin that lets you set up redirects, optimize your content for search engines, and more.

The first thing you need to do is install and activate All in One SEO (AIOSEO). Check out our step-by-step guide to installing a WordPress plugin for more details.

Note: There is a Free version by All in One SEO, but we will use the Pro version since Redirect is a Pro addon.

Once the plugin is activated, you need to go All in one SEO » Redirects.

If you haven’t set up any redirects yet, you need to click the Enable Redirects button.

Enabling redirects in All-in-One SEO

This will install the All in One SEO Redirects module.

Next, you need to click on the “Settings” tab at the top of the page. On this page you can configure redirects in AIOSEO.

The AIOSEO forwarding settings page

You need to scroll down the page until you find the Advanced 404 Settings section. Activate this section by simply clicking the Shift button so that it turns blue.

Now you can see some more settings. You should toggle the “Enable default 404 redirect” button to “On”. After that, make sure that the “Homepage” option is selected.

Enabling the default 404 redirect in AIOSEO

Note that there is also a Custom URL option. This allows you to redirect 404 errors to any post or page. Don’t forget to click the “Save Changes” button at the top or bottom of the page to save your settings.

Now, if your visitors try to go to a URL on your site that doesn’t exist, they’ll be taken to the home page instead of seeing the default 404 page.

Method 2: Redirect all 404 errors to the home page using code

If you don’t want to use a plugin, you can use a simple code snippet to redirect all 404 pages to the homepage.

This method requires you to add code to your WordPress files. If you haven’t already, check out our beginner’s guide to inserting snippets from the web into WordPress. You might also want to read our guide to WordPress theme template hierarchy.

First you need to create a new file in your WordPress theme folder and give it a name 404.php. If your theme already has one 404.php file, then you must edit that file instead.

To edit this file, you need to connect to your WordPress hosting account using an FTP client or the file manager tool.

FTP 404 PHP file

Once you’re connected to your website, you can see it 404.php file in your WordPress themes folder.

You need to put the following code as the first line in yours 404.php File:


Next, save the 404.php File and re-upload it to your theme directory via FTP or your hosting control panel.

Now, if a page isn’t found, visitors will no longer see a 404 page, but will be redirected to your WordPress home page.

Bonus: set up custom 404 page redirects with AIOSEO

The best and SEO-friendly way to deal with 404 errors is to redirect visitors to the most relevant page, not just your homepage.

The All in one SEO The plugin’s redirects feature can also track all 404 page errors and allows you to set up smart 404 page redirects in WordPress.

If you have installed and activated AIOSEO If you followed Method 1, all you have to do is navigate back All in one SEO » Redirects page and click the Settings tab.

Next, scroll down until you see the Logs section. Your 404 logs are a record of the URLs your visitors used to attempt to visit pages that no longer exist on your site.

Make sure “404 logs” is checked so it looks blue. You can also choose how long you want the plugin to record your logs by selecting the time period from the drop-down menu.

Enable 404 logs

Don’t forget to click Save Changes before proceeding.

You can then click the 404 Logs menu option to view the last viewed 404 page.

Remember, since you just turned on logging, you might not see anything right away. You may have to wait up to 24 hours before you see useful insights there.

Click the 404 Logs menu option.

The URL column shows the pages that users tried to visit but don’t exist.

You can redirect any of these URLs to an existing page by clicking the Add Redirect link in the Redirect column. This will open a drop down menu where you can enter your forwarding information.

For best results, you must enter the most relevant page for the original query in the Target URL field and then click Add Redirect.

Add homepage redirect

For example, if you deleted a tutorial on how to start a WordPress blog and then wrote a new one, it’s best to redirect that old URL to the new blog post and not your homepage.

To add multiple 404 page redirects, just follow the same steps as above.

Keep in mind that you generally don’t want your 404 page to redirect to your homepage forever. This is a great temporary solution until you create a custom 404 page design that allows for better conversion, or set up individual redirects that direct users to a relevant, existing page.

We hope this article helped you learn how to redirect your 404 page in WordPress. You might also want to see our ultimate WordPress SEO guide and the best drag-and-drop WordPress page builders for creating custom 404 pages.

If you liked this article, please subscribe to ours Youtube channel for WordPress video tutorials. You can also find us on Twitter And Facebook.

RELATED ARTICLES
- Advertisment -