Don wanted a way to block access to his blog while he was fiddling with it. He found information about the 503 code online.

Of course, they want to return different codes for search engines and for users. We figured we wanted to return the same thing for users and search engines; after all "Service Unavailable" is the actual status, regardless of who's visiting. The only exception should be the blog maintainer.

Here's the .htaccess we worked out:

[code] RewriteEngine On RewriteBase /serendipity # Allow blog maintainer back in RewriteCond %{REMOTE_HOST} !^your\.IP\.address\.here # Don't loop forever RewriteCond %{REQUEST_URI} !^/503\.php RewriteRule .* 503.php [L] [/code]

And here's the 503.php file I like:

[code] Get Off My E-Lawn!

Get Off My E-Lawn!

I'm busy maintaining the site. Please don't step on the grass.

I should be ready for visitors again in under an hour.


We use a PHP file so that we can set the header, and so we can include a retry period for search engines.

If you're one of the few whose server allows [R=503] in the .htaccess, there's an even easier way outlined in the article details.

I didn't really want to have a separate document for my maintenance, and I especially didn't want to run PHP just to output the appropriate header. Unfortunately, my server doesn't allow [R=503] in my .htaccess files. If yours does, and you have mod_headers installed, you might try this, instead:

[code] RewriteEngine On RewriteBase /serendipity ErrorDocument 503 "Down for maintenance. Check again in an hour. # Allow blog maintainer back in RewriteCond %{REMOTE_ADDR} !^your\.IP\.address\.here # Set environment variable RewriteRule .* - [E=maintenance:1] # Add retry timeout if maintenance mode is enabled Header always set Retry-After "7200" env=maintenance # Redirect with 503 if maintenance mode is enabled RewriteCond %{ENV:maintenance} 1 RewriteRule .* - [R=503,L] [/code]

That's nicely and fully contained in the .htaccess... if you can get it.