Serves a file maintenance.html
for every request while it is present.
No need to restart the web server or alter its configuration to switch
the site into maintenance mode.
<Directory /var/www/site>
Allow from all
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
# Every request:
#RewriteRule ^.*$ %{DOCUMENT_ROOT}/maintenance.html [L]
# Still provide meta data:
RewriteRule ^(?!(favicon\.(ico|png)$|(robot|human)s\.txt$|sitemap\.xml$)).*$ %{DOCUMENT_ROOT}/maintenance.html [L]
</Directory>
location / {
root /var/www/site;
index index.html;
try_files /maintenance.html $uri $uri/index.html $uri.html /fallback/index.html;
}
location ~* ^/(favicon\.(png|ico)|(human|robot)s\.txt|sitemap\.xml)$ {
root /var/www/site;
}
Tested with Apache 2.4.6 and Nginx 1.8.0 on CentOS 7.1