Simple Solution on How To Redirect 404 Error

For some reason when Google crawls my site it is adding /contact-me at the end of most my urls. After checking in with Google webmaster tools, I learned that I had 390, 404 not found pages! Wow that is a lot, so I started looking at the crawl errors, found out for some reason my site map via Google had not been updated since October of 2010, why I have no clue, so I went ahead and did a force update, now I am waiting on Google to do another crawl. I was still kinda bummed about all these 404 page not found, so I used Google like I always do when I have a problem.

I searched “how to set up a wordpress redirect of 404 page to home page” got a lot of hits, tried several different things, including editing my .htaccess file, nothing worked then I came across this message board, read through it and a guy gave the perfect fix!

I recommend you first make a back-up of the file only because it is the smart thing to do. Go into your theme, and under Editor, you will find a file called 404.php this file tells your blog what it should do when it comes across a page that doesn’t exist, you want to remove all that code, then add the code below.

<?php //Simple Redirect for WordPress. //Christopher Carey //301 Redirect for WordPress //http://wwww.noheat.com header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url')); exit(); ?>

Save the file, then goto a page that doesn’t exist and bam it should take you back to your home page! Hopefully when Google comes and crawls my site again all my 404 Not Founds will be gone!

About Jammie Morey

Jammie is of Native American descent, her family is from the Ojibway/Chippewa tribe in Mount Pleasant, Michigan. She was born and raised in Michigan and currently resides there with her daughter. She is a single parent and enjoys spending time with her daughter. Jammie is a home healthcare aide and loves what she does outside the home. Jammie is Owner of The Neat Things in Life.

Comments

  1. Thanks for the walk through…I think I got it fixed…Hopefully I’ll see something new going on here soon.

    • your welcome. I think you can change the ‘url’ to a different page and redirect them to another page, but I have not tested that.

Speak Your Mind

*

The Neat Things in Life is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com