First Page Fitness: Blog | Site Map | Home |

The Health and Fitness Marketing Blog

Industry News and Fitness Products

Health and Fitness Products Blog

Getting Custom 404 Page to Show 404 Error Code Instead of 200 Status

Creating a custom 404 page is a great way to keep your visitors, even when they mistype a URL or are arriving from a broken link. The problem, however, is that webmasters often neglect to ensure the proper Http header status code is showing. Because the server returns a page, it thinks everything is hunky-dory (wow, I think that’s the first time I’ve ever typed those words) and provides the 200 Status OK to your browser, a search engine spider, or Google Sitemaps when they verify your account.

Does this sound familiar: “Unable to verify sitemap. We’ve detected that your 404 (file not found) error page returns a status of 200 (OK) in the header.”

If so, you would have had to take one of three actions:
1. Delete your custom 404 page and resort back to that old ugly default.
2. Forget about verifying your Google Webmaster Tools Sitemap.
3. Fix the problem.

If you opted for #1 or #2, I think this blog entry might be able to help.

There are a number of ways to force a custom 404 page to return the proper header response. Using PHP and ASP are two of them, but perhaps the easiest way to get the correct status code is by ensuring the path to your custom page in the .htaccess file is relative - not absolute.

Huh? What’s that? Relax. If you use a service like Hostgator, Ipower Web, etc. they probably provide you with a ”cpannel” or “vdeck” where you can make changes like specifying a custom 404 page or redirecting a certain page without having to get all technical. But what is happening behind the scenes is that they are writing to something called a .htacess file. You can change this file yourself, or perhaps get tech support to do it for you. Often, it will be a “hidden” file and you will need to go into preferences and select “view hidden files” or “view system files” in order to see and edit it. But, back to the point…

Look for the following code in your config or .htaccess file (with a different domain, of course):
ErrorDocument 404 http://www.firstpagefitness.com/error.html
This returns a 200 ok code because it is a full path (includes the entire URL)

You want to change that so it looks like this:
ErrorDocument 404 /error.html
This returns a 404 error status because it is a relative path (no domain name - Just the file name and whatever folder it is in. In this case, it is the root folder.)

Again, there are other solutions for PHP, ASP, Word Press blogs, etcetera. Leave a comment if you truly need one of these solutions and I’ll try and point you in the right direction. But doing it this way will work for most people with a normal site on an Apache / Linux server.

Now you can verify your Google Webmaster Tools Sitemap Account!

1 Comment

  1. Worked like a charm and everything is hunky-dory now…thanks!

    Comment by Christopher — February 5, 2007 @ 11:56 pm

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

RSS Feed for Health Care and Fitness Website Marketing Tips by First Page Fitness
del.icio.us Health and Fitness Marketing Tips
Add to My Yahoo!
Subscribe with Bloglines

Furl Health and Fitness Marketing Tips
Add to Technorati Favorites!

ss_blog_claim=4f09232db25bb8aa534459b9e02828ad