Forum Moderators: phranque

Message Too Old, No Replies

Blocking Java Bots

         

AjayDSouza

6:25 am on Feb 19, 2006 (gmt 0)

10+ Year Member



Following this post:
[webmasterworld.com...]

I tried to reply but was unable to, hence the new topic.

I tried adding


# Block Java and Python URLlib except from Google and Yahoo Python
RewriteCond %{HTTP_USER_AGENT} ^(Python[-.]?urllib¦Java/?[1-9]\.[0-9]) [NC]
RewriteCond %{REMOTE_ADDR}!^207\.126\.2(2[4-9]¦3[0-9])\.
RewriteCond %{REMOTE_ADDR}!^216\.239\.(3[2-9]¦[45][0-9]¦6[0-3])\.
RewriteRule .* - [F]

However, the server throws up a 500. When I use just

^(Java/?[1-9]\.[0-9)

then it works perfectly as checked from wannabrowser [wannabrowser.com]

However, using

^(Python[-.]?urllib¦Java/?[1-9]\.[0-9]) [NC]

doesn't block the java user agent.

Finally, I tried adding the last two lines to allow google and yahoo, but then got the 500 error.

Any suggestions / solutions. I am a bit worried I block out Google and Yahoo bots while trying to block the bad Java ones.

Mokita

6:51 am on Feb 19, 2006 (gmt 0)

10+ Year Member



The code you quoted is missing spaces in two crucial places - which would cause 500 server errors. Add a space between %{REMOTE_ADDR} and the exclamation mark (!) on two lines.

And then change all the broken pipes (¦) to a solid pipe using your keyboard (this forum changes solid pipes to broken)

AjayDSouza

7:18 am on Feb 20, 2006 (gmt 0)

10+ Year Member



Thank you.

It worked :)