How to redirect 404 error page to WordPress homepage

This article I will guide how to redirect 404 error page to the home page or any page for WordPress.

How to redirect 404 error page to WordPress homepage in the simplest way
How to redirect 404 error page to WordPress homepage in the simplest way

About 404 error Page not found (404 error Page not found) is an error that occurs when the link of that page is no longer available, maybe the page has been deleted or the link (link) of that page has changed. or enter the wrong link address.
A website with a lot of 404 errors often adversely affects a lot of SEO, so you should move this 404 page to the home page or any other page, that is, when users visit a link that does not exist (enter If the link is wrong, the link is deleted or changed), the page will automatically redirect to the homepage or a page of your choice, which means your website will no longer have 404 errors, which is of course very good for SEO. So how to do it? There are many ways and I will guide the easiest ones right now.

Method 1: Use the All 404 Redirect to Homepage plugin

This is the simplest way, after installing and activating the plugin, go to Settings → All 404 Redirect to Homepage and then at 404 Redirection Status select Enabled (on), and at Redirect all 404 pages to be local. Only the page you want 404 redirects to, you can enter the link of any page or leave the default homepage of your website.
For many people who do not like to use the plugin, you can use the following methods 2 and 3, which is very simple.

Method 2: Edit functions.php file

You insert the code into the functions.php file:
  If you want to redirect to another page (not the homepage) then you change the url in the get_bloginfo (‘url’) function to the link of the page you want to redirect to.

Method 3: Edit the 404.php file

If the theme you use has a 404.php file, you can use this method, insert the following code into the 404.php file (can remove all the old code).
  Similarly, if you want to redirect to another page (not the homepage) then you change the url in the get_bloginfo (‘url’) function to the link of the page you want to redirect to.
  Ok, got it done! Remember to leave your comments below!

Leave a Reply

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