If you’re working on updating or rewriting a production site, it may be useful to have a mod_rewrite rule that will automatically send all traffic–except IPs you specify–to a maintenance page. This will let you communicate to your users while still allowing you and your staff to work on the site unhindered. In this case, 25.254.253.252 and 1.2.3.4 will be allowed to visit the site as normal, and everyone else would be redirected.
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !255.254.253.252 [NC]
RewriteCond %{REMOTE_ADDR} !1.2.3.4 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !maintenance.html$ maintenance.html [R=307,L]
Recent Comments