Skip to main content

Rackspace CloudSites and .htaccess maintenance mode

We’ve started using Rackspace’s CloudSites at BERG, and one of the problems we’ve been tackling is how to make deployment a painless process. Uploading to CloudSites is only allowed by FTP/SFTP, and is very slow at times, so we wanted to use a “maintenance” mode approach that is common in the Rails and Capistrano world.

CloudSites has some very customised Apache configuration, and we found that the standard mod_rewrite approach didn’t work. There was no mention of a solution within their support wiki, so for anyone else looking for a similar solution, I’m placing ours here:

RewriteEngine on
RewriteBase /
RewriteCond %{ENV:PHP_DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !/maintenance.html
RewriteRule ^.*$    /maintenance.html [L]

We found that when checking the DOCUMENT_ROOT environment variable, it didn’t get the correct path to test for the presence of the maintenance.html file, but using ENV:PHP_DOCUMENT_ROOT, it did.