[Web4lib] htaccess to block multiple IP addresses
Chris Gray
cpgray at library.uwaterloo.ca
Thu Jun 23 10:00:04 EDT 2005
On Thu, 23 Jun 2005, VanderHart, Robert wrote:
> I'm trying to block bots that don't obey the robots.txt directives.
> We're using Linux/Apache 1.3. I was wondering if the following syntax
> is correct in an .htaccess file in our root directory:
>
> <Limit GET POST>
> order allow,deny
> allow from all
> deny from 213.239.236.18
> </Limit>
>
> <Limit GET POST>
> order allow,deny
> allow from all
> deny from 65.19.150.232
> </Limit>
The above can be reduced to:
<Limit GET POST>
order allow,deny
allow from all
deny from 213.239.236.18
deny from 65.19.150.232
</Limit>
or even:
<Limit GET POST>
order allow,deny
allow from all
deny from 213.239.236.18 65.19.150.232
</Limit>
Also the <Limit> tag around it isn't necessary if you're doing this in an
.htaccess file and you want to block all access to those IPs including
other HTTP directives, such as HEAD, as well as just GET and POST.
> 1) Is this the only way to block several IP addresses from different
> ranges?
In Apache, essentially the answer is yes. On Linux you can also use
iptables or you can use an external firewall.
> 2) Is there a more efficient way to block nasty robots?
If by "more efficient" you mean automatic, then yes. Have a look at
<http://www.leekillough.com/robots.html>.
Cheers,
Chris
More information about the Web4lib
mailing list