How to redirect 404 to home page

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

Posted on

404 page is part of every WordPress and non WordPress websites.

While working on WordPress you can write the designing code or 404 template file for your 404 page of the website. If you are in hurry to go live without 404-page design then there is a small coding trick that all 404’s page users will redirect to your Homepage.

In this very short article, we will provide you with the small piece of PHP code that redirect your 404 visitors to your website homepage.

It’s very simple, all you need to do is open your theme folder and 404.php file ( if not please create one ) and write the following code there and simply save it.

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

That’s all. when a user hits a 404 page will redirect to the homepage.

Note: This trick should be used if you are in hurry. But we recommend to track your 404 page and make proper design and redirect your user to proper 404 page.

themeegg

ThemeEgg is beautiful, modern, clean, responsive, SEO friendly, premium and free WordPress theme and plugin store. We have highly customizable and good looking WordPress themes and plugins to create a beautiful website. We can also provide themes and plugins customization support.

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

  1. Wow, awesome weblog structure! How lengthy have you been running a blog for? you make running a blog glance easy. The overall look of your site is excellent, let alone the content!

  2. I do accept as true with all of the concepts you’ve offered to your post. They are very convincing and will definitely work. Still, the posts are very brief for starters. May you please extend them a little from subsequent time? Thanks for the post.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.