«»

Technicality

· 21ST OF AUGUST, THE YEAR 2006

.HTACCESS TO DIVERT TRAFFIC BY IP ADDRESS

I had to take down a site for updates today, so I decided I’d try and use a .htaccess file to redirect all requests to a holding page. Well, all requests other than my own, of course, since I needed to test things. My .htaccess file looked like this:

# Need to have FollowSymlinks for mod_rewrite to work its magic
Options +FollowSymlinks

RewriteEngine on

# You might want to set the base of the rewrites (where Apache should look f
# or the places to which you're redirecting)
# RewriteBase /

# Rewrite URL for all REMOTE ADDRESSES except mine
RewriteCond %{REMOTE_ADDR} !^1.2.3.4

# Send all requests to index-maintenance.html using a pass through, so the
# request URL looks the same
RewriteRule /* index-maintenance.html [PT]

Cribbed from here and here.

NO COMMENTS YET

Comments are closed.