503 HTTP Status Code when Site Down
If for some reason you must take down your site or just a few pages temporarily for maintenance, moving servers, or whatever reason, you need to tell the search engines that this is TEMPORARY. Otherwise, they will see the page is not there (404 status/response code) and drop your site or page from their search index.
This would obviously not be good.
You tell the search engine that the page is temporarily unavailable using the 503 status code in the http header. In php, you can set the header for the status code like:
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 7200'); // in seconds
In drupal, you can use the equivalent, drupal_set_header function.
You can use .htaccess rules in combinations with a php file to use the 503 status code by:
1) Create a 503 php code page (e.g. error503.php) and put the header code in it like:
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 7200'); // in seconds
print "This page is temporarily unavailable";
2) In the .htaccess file, add in:
RewriteRule .* /[path-to-file]/error503.php
(This will redirect all pages to your error503.php file.)
Or you can only redirect specific pages to the file like:
RewriteRule page.html /[path-to-file]/error503.php
In Drupal, you can use your tpl.php files to deal with returning status codes if you need to. For example, in page.tpl.php, you could do:
<?php
drupal_set_header('HTTP/1.1 503 Service Temporarily Unavailable');
drupal_set_header('Status: 503 Service Temporarily Unavailable');
drupal_set_header('Retry-After: 7200'); // in seconds
print "This page is temporarily unavailable";
?>
Or set up whatever logic makes sense... For example, if all blog pages need to be down and they have a url alias path like "blogs/xxx", you could do
<?php
if (arg(0) == 'blogs') {
// same code as above
return;
}
?>
Using the correct http status codes is very important for SEO. For pages that are temporarily down, use the 503 status code. For pages with new URLs, use the 301 permanent redirect. In Drupal, you can use the Global Redirect module, Path Redirect module, and Search 404 module to help with managing your status codes efficiently.
- kristen's blog
- 186493 reads
This is a featured content block that has been configured to show blog nodes with terms SEO or Drupal SEO by the author kristen. It shows random list of 20 results in the block and 30 results on the more page.
- Drupal Meta Tags (nodewords) Module for SEO
- Make Drupal SEO Friendly
- Basic SEO Top 10
- Drupal Nofollow Link Sculpting
- HTML Validation: Free HTML Validator Tools
- Free SEO Tools
- Drupal Node Teaser SEO
- Drupal SEO Reviews
- Fix Duplicate Content with Global Redirect Module
- Drupal Pathauto Module
- Free Google Keyword Research Tool
- Drupal Pathauto URL Aliases Settings
- Drupal SEO Modules
- Drupal Has Multiple h1 Tags
- BADCamp Drupal SEO Presentation 2009
- Kristen
Comments
Disney could have used this
Disney could have used this last week :) They're site was down for maintenance and the downed site version got indexed in Google which said something like "...come back later site is down..." and that showed up in search results. The problem was that there site was back online but that still showed in Google for several days till they were recrawled! Och!
Very interesting!
Wow, I'm surprised that such a big company like Disney would make that mistake!
I found out about this the hard way as well back in 2004 when I was just learning about this stuff.
Fortunately for Disney, I bet their pages get re-indexed within a few days. For the site I was working on, it took *months*.
Kristen
Thanks, Kristen, it was
Thanks, Kristen, it was really helpful.
HTTP Tool to verify status from URL
I like to use Send HTTP Tool to verify and debug status code from the URL when Im sending different HTTP request to the web.
Try it you may find it useful:
http://www.softpedia.com/get/Internet/Servers/Server-Tools/WIN-HTTP-Send...
Ths is superb..this is exactly what I needed.
Thank you Kristen. This was very helpful. Did not find much on this on drupal.org and your information was golden .. exactly what I was looking for.
-James.
Cool
Glad to hear it ;)