I have this .htaccess file inside DOCUMENT_ROOT where it checks for the existence of a file, maintenance.enable and serves maintenance.html if it is present:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# This portion checks for the presence of maintenance.enable to toggle
# maintenance mode
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
Header Set Cache-Control "max-age=0, no-store"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
However, it doesn't seem to work outside DOCUMENT_ROOT. For example, considering I have a folder structure like this:
document_root/
.htaccess
index.php
maintenance.html
maintenance.enable
test/
.htaccess
index.php
maintenance.enable
maintenance.html
outside_document_root/
.htaccess
index.php
maintenance.html
maintenance.enable
The folder outside_document_root
is defined as an alias in the conf file.