I have just read this article from SmashingMag (#4) regarding a maintenance page for your WordPress blog which you could use while you’re upgrading or maintaining your blog. This quick hack is impressive yet it fails to take into account search engine bots.
Depending on how often crawlers like GoogleBot visit your website you should really think about your search engine rankings. Don’t forget: bots are not able to (at least not yet) understand the page they are accessing. If e.g. GoogleBot revisits your blog to index an article and finds a 302 redirect to your maintenance page this may lead to problems which in the worst case might mean that your maintenance page is being indexed and your previous article content lost for Google – at least as long as your maintenance page is up.
According to Google you should instead return a website with a 503 HTTP status code.
So let’s look at the original code by SmashingMag to put into your .htaccess file:
RewriteEngine on RewriteCond %{REQUEST_URI} !/maintenance.html$ RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 RewriteRule $ /maintenance.html [R=302,L]
The problem lies in the 302 redirect. So let’s just create a maintenance page telling GoogleBot to revisit our website in 30 minutes – you should of course add more informative text than I did to the page:
<?php $minutes = 30; header("HTTP/1.0 503 Temporarily Unavailable"); header("Retry-After: ".$minutes*60); ?> <html> <head> <title>Maintenance</title> </head> <body> <h1>Maintenance - Please come back later in approximately <?php echo $minutes; ?> minutes.</h1> </body> </html>
Now the mod_rewrite rules in the .htaccess file need to be modified as well (assuming the file above would be saved as maintenance.php in the document root directory):
RewriteEngine on RewriteCond %{REQUEST_URI} !/maintenance.php$ RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 RewriteRule $ /maintenance.php [L]
That’s all – you’re done. After you have finished your maintenance work you just need to disable the rewrite rules by prefixing each line with a “#” symbol.




