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

Breaking

Saturday, June 26, 2021

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

Do you want to redirect your 404 page to your home page in WordPress?

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

In this article, we’ll show you how to redirect your 404 page to your home page in WordPress, step by step.

How to redirect your 404 page to the home page in WordPress

Why Redirect Your 404 Page to Your WordPress Home Page?

If you haven’t had the time to create a custom 404 page, then redirecting visitors to your home page can be a great solution.

When a user requests a page that doesn’t exist on your WordPress website, then WordPress will show them a 404 error page instead.

Default WordPress 404 page

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

One way to keep your users engaged is by redirecting them to another more relevant page. Some website owners choose to take the shortcut and redirect users to homepage.

In the perfect world, you’ll redirect specific 404 error requests to a more relevant page.

That being said, we’ll show you two ways you can redirect your 404 pages to your home page as well as custom pages in WordPress.

Method 1: Redirect All 404 Pages to Home Page in WordPress

This method uses a simple code snippet to redirect all 404 pages to homepage. If you want to see how to redirect individual 404 pages to more relevant pages, see method 2 in this article.

In this method, you need to add code to your WordPress files. If you haven’t done this before, then see our beginner’s guide on pasting snippets from the web into WordPress.

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.

FTP 404 php file

Once you’re connected to your website, you will be able to see your 404.php file in your WordPress themes folder.

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 reupload 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.

Method 2: Use AIOSEO to Set up Custom 404 Page Redirects in WordPress

The best and most SEO friendly way of handling 404 errors is to redirect them to the most relevant page, not just your homepage.

This is where All in One SEO plugin comes in. It’s the best SEO plugin for WordPress used by over 2 million websites.

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 AIOSEO. For more details, see our step by step guide on how to install a WordPress plugin.

Note: there is a free version of All in One SEO, but we’ll be using the pro version since Redirect is a Pro addon.

Once the plugin is activated, you need to go to All in One SEO » Redirects. If you haven’t set up redirects yet, then you need to click the ‘Activate Redirects’ button.

Activate AIOSEO redirects

Once you’ve done that, you need to click on the ‘Settings’ menu item and enable 404 logs.

Next, scroll down until you see the ‘Logs’ section and then click the ‘404 Logs’ toggle, so it turns blue.

Enable 404 logs

Your 404 logs are a record of URLs that your visitors have tried to use to visit pages that no longer exist on your site.

You can choose how long you want the plugin to record your logs by selecting the time period from the drop down menu.

Make sure you click ‘Save Changes’ before moving on.

After that, click on the ‘404 Logs’ menu option to see the last accessed 404 page. Remember, since you just enabled logging, it may not display anything right away. Give it up to 24 hours to see more useful insights there.

Click 404 logs menu option

The ‘URL’ column will show you the 404 page the user tried to visit. You need to click the ‘Add Redirect’ link in the ‘Redirect’ column.

This will create a drop down where you can enter your redirect information.

For best results, you need to enter the most relevant page to the original query in the ‘Target URL’ box and then click ‘Add Redirect’.

Add home page redirect

For example, if you had a tutorial on how to start a WordPress blog that you deleted and updated with a new one, then it’d be best to redirect that old URL to the new blog post rather than your homepage.

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

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.

We hope this article helped you learn how to redirect your 404 page in WordPress. You may also want to see our guide on the best drag and drop WordPress page builders to create custom 404 pages and our expert picks of the must have WordPress plugins for businesses.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Redirect your 404 page to the Home Page in WordPress appeared first on WPBeginner.

No comments:

Post a Comment