How to Allow & Deny by IP Address
Author: Mitch Keeler
Having issues with somebody at a particular IP address that is giving you problems? Are they bugging your users or poking you with the proverbial stick of annoyance? Well with the power of a little creativity and your .htaccess file you can help them find their way to the “Hey, hit the bricks!” door and hopefully the said door will hit them on the way out too.
To get this done, all you need to do is add this to your .htaccess file:
order allow,deny deny from XXX.XXX.XXX allow from all
Just replace the “XXX.XXX.XXX” with the IP address you wish to block. You can also add a second line like this if you wish to block multiple IP addresses:
order allow,deny deny from XXX.XXX.XXX deny from MMM.MMM.MMM allow from all
One last tip. If you want to block everybody from seeing your web site, just put in deny from all.
order deny,allow allow from QQQ.QQQ.QQQ allow from LLL.LLL.LLL deny from all
This would turn everybody away except for the people who have the IP address QQQ.QQQ.QQQ and LLL.LLL.LLL.
For more help with getting this done, check out the official Apache page on the process:
http://httpd.apache.org/docs/1.3/mod/mod_access.html



