.htaccess – Block Everyone Except One IP Address
Monday, February 5th, 2007This will be really useful for me while I overhaul the Grocist database. The instructions are here:
http://www.htaccesselite.com/htaccess/block-everyone-except-1-ip-address-vt43.html
Now, one problem I ran into is that my server was seeing my IP address as something different than www.whatismyip.com was reporting.
Here’s a cheap trick I used to find out what .htaccess was actually seeing from me:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^172\.21\.0\.201$
RewriteRule ^(.+) http://www.blendedtechnologies.com/%{REMOTE_HOST}
Thus since I did not yet have my correct IP address filled out above, it took me to the link above with my correct IP address as the “subdirectory”.
Once I found out my correct IP address I filled in my final .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^172\.22\.1\.201$
RewriteRule ^(.+) http://www.blendedtechnologies.com/maint.html
Does anyone know why I would get conflicting answers for what my IP address is between .htacccess and everything else? Is %{REMOTE_HOST} reporting something different?