To leave a comment, please Login or Register

1: How to Redirect 404 Page to Home Page Using Code

You can redirect all 404 pages to homepage by using custom code in your site. Simply, you need to add the code to your WordPress file.

First, you 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, you'll need to edit the file.

And then you need to add the following code to your 404.php file:


header("HTTP/1.1 301 Moved Permanently");

header("Location: ".get_bloginfo('url'));

exit();

?>

After this save your 404.php file. Now, when a visitor visits the 404 page of your site, he/she will be redirected to the home page.

2: How to Redirect 404 Page to Home Page Using Plugin

If you are afraid of adding code to your site, you can use a plugin.

First of all install and activate Redirection plugin on your site. After activating the plugin, click on Tools >> Redirection and follow the below screenshot.


Here you add your 404 Error Page in the Source URL field and add the Home Page URL in the Target URL field. After that leave the rest of the settings as default.

After adding your URL click on “Add redirect”. Now to test it, you can click on the URL with 404 not found.
23 days ago   0