Wordpress Database Error Page and Search Engines
WordPress 2.3.2 is now available and with it comes the new ability to create your own custom database error page.
This is a nice feature in my opinion, as not only does it hide possibly sensitive information about your database it also allows you to create a friendly error message for the less computer savvy among us. A possible example would be a simple message telling the user that something has gone wrong and they should check back later. It’s as easy as creating your custom error page and uploading it to /wp-content/db-error.php
Then I got thinking. What about our old friend Mr Search Engine?
What would happen if he decided to pay a visit while the database was having a seizure? Well for starters the page would be returning the HTTP 200 status code, which would cause the search engine spider to assume everything is fine and dandy. Not only that, just about every page would be serving the custom database error which would be seen as duplicate content. Uh oh.
Luckily the WordPress developers allow us to use PHP in the custom error page, so it becomes trivial to rectify this.
The HTTP 503 status code does the trick here, coupled with the Retry-After header. Retry-After is measured in seconds so in my example I’m telling the spider to come back after one hour (3600 seconds), like so:
<?php
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
?>
... your error page html content here ...
The search engine spider now knows that all is not as it should be and that it should check back in an hour.
The possibilities here are endless if you know your way around PHP. The error page could send an email or SMS to the site administrator and much more, however this is outside of the scope of this article.
Thanks a lot for this post
So how do you do this when your writing job keeps you tied to your desk? ,
Other people like to think of the glass as half empty. ,