Here is the minimal (and the ultimate) rewrite rules to put a website in maintenance mode, works for Apache 2.x:
Options FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteEngine on
RewriteCond %{REQUEST_URI} !\.gif$ [NC]
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteRule $ /maintenance.html [R=307,L]
If you have anothers ressources in the maintenance.html page, like a css or js files, add more RewriteCond conditions:
RewriteCond %{REQUEST_URI} !\.css$ [NC]
RewriteCond %{REQUEST_URI} !\.js$ [NC]
RewriteCond %{REQUEST_URI} !\.png$ [NC]
Also, you can add a RewriteCond conditions to bypass the maintenance mode from a specific IP (or subnet …):
RewirteCond %{REMOTE_ADDR} !xxx\.xxx\.xxx\.xxx
Don’t forget to activate the rewrite module in Apache2, on a Debian:
# a2enmod rewrite # apache2ctl configtest # /etc/init.d/apache2 reload
Externals resources:
0 Responses to “Rewrite rules for maintenance”