Published : 2011-03-18

Maintenance mode

Keeping your services up is essential. If you are not running a load-balanced or high-availability setup, sometimes you have to take services down for maintenance. The HTTP protocol defines a return code for a temporarily unavailable or in-maintenance service (HTTP status 503).

Prerequisites

The mod_rewrite module must be enabled.

Configuration

Open the configuration of your VirtualHost and simply add the following lines:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/down.html [NC]
RewriteRule .* /down.html [R=503,L]

With these lines active, your server is in maintenance mode. You can create a down.html page to customize the notice.

These lines can of course be reused to generate other error codes as well.