Even though Google and other crawlers should recognize the 302 as a temporary relocation I like to avoid sending any page redirection headers.
I send out a "503 Service Unavailable" code instead, which indicates the server is down or undergoing maintenance. Instead of redirecting it to a HTML page I recommend you yend it to a php script which gives the maintenance message:
<? header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Retry-After: 600'); // Retry after 10 minutes echo 'Your maintenance message here."; ?>
g1smd
9:11 pm on May 29, 2012 (gmt 0)
The 503 status is the correct one to use.
Downtime of only a few hours is no worry whatsoever. Google will be back in there in short order soon after the stated expiry time.
abushahin
10:41 pm on May 30, 2012 (gmt 0)
Thanks for the correct error code. Is there anyway to allow some folders though using htaccess whilst redirecting all root visiters?
g1smd
10:54 pm on May 30, 2012 (gmt 0)
Be clear, this is NOT a redirect. Redirects return a 30x status code.
This is a method of returning an alternative status code and a human-readable message for some vistors.
Use a series of RewriteCond conditions to select which vistors and/or which user agents see the message and which do not and/or which paths and files are accessible and which are not.
motorhaven
11:07 pm on May 30, 2012 (gmt 0)
Noticed a mistake in my code. The echo should end with a single ' quote, not a double " quote.