Adventures with Mod Rewrite
MicroGuy | October 15, 2009
Yesterday, I was desperately seeking ways to waste loads of time when along comes Mod Rewrite.
I’m a reluctant user of Statpress Reloaded (due to buggy database bloat) but do enjoy examining site visitor data during uncontrolled bouts of time wasting. Occasionally I will see unwanted guests browsing my archive of random musings. This is a problem for which I have found a cure. It’s called Mod Rewite.
Let’s say you see someone from 10.10.10.69 reading your private thoughts. Let’s say you don’t like repeating 10’s in IP addresses and let’s also say you’re an IP snob. If you’re running Apache, do this:
1. Modify or create an .HTACCESS file and place it in the root folder.
2. Add something like this to the file:
RewriteEngine On
RewriteBase /
# Redirect specific IP address
RewriteCond %{REMOTE_ADDR} ^10\.10\.10\.69 [OR]# Redirect Class C subnet
RewriteCond %{REMOTE_ADDR} ^10\.10\.10 [OR]# Redirect Class B subnet
RewriteCond %{REMOTE_ADDR} ^10\.10RewriteCond %{REQUEST_FILENAME} !-f
# Name of file to redirect
RewriteRule !down.htm$ down.htm [R=307,L]
Now when pesky visitors return from those ranges, they will be directed to the specified HTML page.



