WordPress Tweaks & Tuts?

Subscribe to TheCreatology via RSS | Email

How to redirect 404 error page to Homepage in WordPress ?

by Aky Joe

In my previous article I explained about significance of 404 error page in website development. If you missed it, then you can read it here Create 404 Error page to decrease bounce rate on WordPress.

404 error redirect to homepage

Road block 404 Error, redirect to Home

The WordPress 404 error page is usually custom coded, and hence it can be enhanced as per our requirements and needs. In this article we will learn how to redirect 404 error page to homepage in WordPress.

Redirect 404 error page

Below is a simple procedure to add redirection on 404 error page to homepage of blog.

  • Navigate to Theme Directory and locate 404.php file.
  • If found, open it in any text editor. If you couldn’t find one, then just read how to create 404.php file in wordpress.
  • Copy the below code snippet, and replace it completely with existing code.
<!--?php $URL= get_bloginfo('url'); header("Location: $URL"); ?-->
  • Done adding the code ? Now, save the file and upload it to server.

We are done!

Adding the above code, will redirect any visitor to Blog’s homepage, if encountered any error or broken links. In a way it can be modified to set custom link as well. only thing is you need to edit line number 3 and add the custom like after “Location: http://www.thecreatology.com”.

If you think its complex then you can hire me for this virtual assistance.

Similar Topics: ,

TheCreatology Support

Got a Query? We're ready, Just Say it!

If you have a doubt or a feedback, then get-in-touch with TheCreatology Support Team now.

Start a Hangout or Email Us

Are you looking for...

  • Logo Design
  • Web Development
  • Thesis Skin Design
  • Graphic Designing
  • Virtual Assistance
Hire Us!


{ read them below or add one }

Roezer April 20, 2011 at 3:25 am

I had a problem with my Hostgator 404 page they were showing Hosting Ads for my 404 pages they were using my referral link in the 404 page but the people visiting my site were looking for help with their computers or something like that they were not looking to buy a hosting package. Another thing some may think that a funny 404 page with a caption is cool I find them as useless as normal 404 pages. With a 404 page if you are not going to redirect to your homepage at least include a search box or some links that may interest the visitor otherwise they will just click the back button on their browsers.


Aky April 20, 2011 at 11:21 pm

I agree with you Roezer, 404 error pages are mandatory and one should optimize and enhance it for better blogging. 🙂


pethum November 24, 2011 at 7:04 am

I had a blog and recently I found virus on it,So hosting people ask me to remove all my content and rebuild it. This is very helpful to me as now I can redirect my visitors from previous backlinks to home page.

Thank you.


john April 25, 2012 at 2:31 pm

i love to use this trick to redirect the uncovered link to home page, but it good for seo?


Aky Joe April 25, 2012 at 7:24 pm

Answer to your question, Redirecting 404 Error Page is good or bad for SEO ? has always been mystery for people, including me. But my insights about SEO says, it is not good to redirect 404 error page as if any visitor open broken link or wrong URL then visitor will not realize if there was an erroneous URL and will be redirected to homepage. Which visitor may not like or face ambiguous situation, hence decreasing SEO score.

Also, according to Google SEO Basics, it is mandatory to have a 404 Error Page in your website. No matter what you type in that! 😛

I hope it helps you to get out of this dilemma or just join the confused club. Cheers! 😉


neene January 8, 2013 at 5:04 pm

Hi i used your trick but its not working on my wordpress blog.

Broken urls are not redirecting to home page…


Alex October 25, 2017 at 3:34 am

I always redirect all 404 to homepage for smaller website:

And no, never got any SEO problems or Google issue. Actually, it’s helping my rankings.


Leave a Comment

Previous post:

Next post:

Contact Aky

Yes, I agree that all information above is valid.

Simple question, what's...