Blocking users based on IP address from your website
Heres a really quick method of blocking users from accessing your website using the common mod_rewrite and .htaccess. For this method to work, you need to have FTP access to your website and be able to put this file in your main webpage directory or sub-directory that you want to limit access too.
I use this method during development mostly, to block prying eyes from viewing my raw files and open indexes.
First of all, if your not already using a .htaccess file, create one in the directory of your choice, if you are using one, and don’t have the next line somewhere in your file, put this line at the top.
RewriteEngine On
This turns the RewriteEngine On. Which is required for blocking the IP’s.
RewriteCond %{REMOTE_ADDR} !^192.168.1.100$ RewriteRule .* - [F,L]
Add the above code underneath the RewriteEngine On and you will block any IPs other than the one listed, to add more IPs, copy the RewriteCond statement and change the IP address.
Alternitave to the above you can also:
Order Deny,Allow Deny from 192.168.1.100 Deny from 192.168.1.101
Which works without mod_rewrite and relies on mod_access. Either/or, take your pick and use whichever one suits you best, results may vary.
I will make a online tool for this in a few days. Hope this comes in handy.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
No comments yet.
Leave a comment