WordPress

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

When coding a one page site, you might not have the time to create a custom 404 page. In which case, you might as well redirect the 404 page to your site’s homepage. In this article, we will show you how to redirect 404 page to home page in WordPress.

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

Redirect your 404 page to the Home Page without plugin

All you have to do is open your 404.php file in your theme’s folder. If it doesn’t exist, then create a blank php file.

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

That’s all. Now when a user hits a 404 page will be redirected to the homepage.

Redirect your 404 page to the Home Page with plugin

Are you experiencing a lot of 404 page not found errors in WordPress? 404 errors are not good for your site’s SEO and user experience. The good part is that they’re quite easy to fix with WordPress 404 redirect plugins.

The best way to fix that is by redirecting users to new location. You should also inform search engines about the new location of those posts and pages by adding a 301 redirect header message.

Let’s take a look at some of the most popular 404 redirect plugins for WordPress that can help you manage these issues.

Post Comment