This has been tested with Plone behind Apache but should apply to any site with Apache as a front server.
In maintenance mode we want Apache to serve a single static page with its associated ressources, and have any other requests redirected to this page. The static files are:

  • maintenance.html : the main file
  • ressources/ : directory containing CSS, javascript, images...
  • robots.txt (instruct to not index maintenance.html)

To create a page with the same design of the real site the firefox extension Save Complete is of great help.

There is 2 strategies:
  • Doing it dynamically by testing a parameter; in our case it will be the presence of a file
  • With an alternative configuration file, swapped with the normal one at maintenance time
In this example we are running a plone site on the same host, port 8080.

1. Dynamically:

DocumentRoot /static/files

Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
Satisfy all

DirectoryIndex maintenance.html

RewriteEngine on

The next rule tests the presence of the regular file "/some/path/maintenance.txt"; if it exists we set the environment variable "MAINTENANCE" to 1.
RewriteCond /some/path/maintenance.txt -f
RewriteRule ^(.*)$ - [env=MAINTENANCE:1]
In maintenance mode we want the browser to never perform any cache: as soon as we'll return to production mode, the normal site should appear. Important: the headers module must be enabled.

Header set cache-control "max-age=0,must-revalidate,post-check=0,pre-check=0" env=MAINTENANCE
Header set Expires -1 env=MAINTENANCE

Next rule instructs to let pass any request matching maintenance files (maintenance.html + CSS/JS/images ressources), else redirect to the maintenance page.

RewriteCond %{ENV:MAINTENANCE} 1
RewriteCond %{REQUEST_URI} ^/ressources [OR]
RewriteCond %{REQUEST_URI} ^/maintenance.html [OR]
RewriteCond %(REQUEST_URI) ^/robots.txt [OR]
RewriteRule .* - [L]

RewriteCond %{ENV:MAINTENANCE} 1
RewriteCond %{REQUEST_URI} !^/maintenance.html
RewriteRule ^.* /maintenance.html [L,R]

The next and last rewrite rule is for normal mode.

RewriteCond %{ENV:MAINTENANCE} !1
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/plone/site/VirtualHostRoot/$1 [P]

Now, to put the site in maintenance mode, just do "touch /some/path/maintenance.txt"; delete maintenance.txt to go back in normal mode.
2. Using an alternative configuration file:

This case is much simpler. First create a static configuration:

DocumentRoot /static/files
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/ressources [OR]
RewriteCond %{REQUEST_URI} ^/maintenance.html [OR]
RewriteCond %(REQUEST_URI) ^/robots.txt [OR]
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI} !^/maintenance.html
RewriteRule ^.* /maintenance.html [L,R]

Header set cache-control "max-age=0,must-revalidate,post-check=0,pre-check=0"
Header set Expires -1


On Debian this file must be placed in /etc/apache2/sites-available. If the site configuration file is named "plone", you can name its maintenance counterpart "plone-maint" for example. To switch to maintenance mode:

> sudo a2dissite plone
> sudo a2ensite plone-maint
> sudo /etc/init.d/apache reload

To go back to normal mode just switch "plone" and "plone-maint".

Enhancement not covered here:

While the site is supposed to show a maintenance page, it may be desirable to let the maintainer access the site through apache: this should be done with a rewrite condition/rule placed first (condition based on Ip address for example).