Apache Redirecting All Traffic Except for 1 IP

By Paulus, 27 May, 2010

Occasionally you will need to modify a live site for maintenance reasons and sometimes you will not always have the luxuery of being able to flip a switch and put the site into maintenance mode. If you are running Apache, then you can redirect everyone else but you or a select few to a 'maintenance page'

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1\.2\.3\.4
RewriteCond %{REQUEST_URI} !/offline\.html$
RewriteRule .* /offline.html [R=302,L]

The first RewriteCond should be the IP you're coming from.
The second RewriteCond prevents a redirect loop. You can direct users elsewhere by changing the offline.html to maintenance.html or whatever you like.