Friday, November 28, 2008

Redirect all requests except for a designated IP with Apache

Redirect all requests except for a designated IP address somewhere else, useful for site maintenance. Put the following in your Apache config: RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteCond %{SCRIPT_FILENAME} !offline.html|logo.png$
RewriteRule ^(.*)$ http://example.tld/offline.html [R]
[R] means force a redirect, defaults to a 302 - moved temporarily.

No comments:

Post a Comment