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.

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. Paste the following code in there:

1

2 header(“HTTP/1.1 301 Moved Permanently”);

3 header(“Location: “.get_bloginfo(‘url’));

4 exit();

5 ?>

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

Note: This should be used in very specific cases. In most other cases (i.e blogs, portfolios etc), you should track your 404 pages and redirect them appropriately.

Looking for quality WordPress Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , | Posted under WordPress | RSS 2.0

Author Spotlight

TJ Marsh

TJ Marsh

My name is Tj Marsh. I spend about 16 hours a day on the internet. Running my company and helping out here at Arvixe. I live in the good ole Arizona where it gets ridiculously hot. I love WordPress and a lot of other open source software along with coding.

Leave a Reply

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


7 − = 5

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>