adding new rule for agent; not working as expected

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 4
Joined: 22 Apr 2013, 14:51

adding new rule for agent; not working as expected

06 May 2013, 22:19

My RewriteCond is working for the REMOTE_ADDR header; it catches the ipaddresses from multiple regex expressions and redirects them correctly:

RewriteCond %{REMOTE_ADDR} (\b101\.\d{1,3}\.\d{1,3}\.\d{1,3}|^\b199\.30\.16\.23|\b46\.119\.\d{1,3}\.\d{1,3})

RewriteRule (.*) http\://www.asdf.com/CASP_BotCatch.aspx\?htaccess=1&agentblock=0&ipblock=1 [I,RP]

Now I want to add a new rule that catches agents that are really bots. I have added this rule:

Here is the agent string: "Java/1.6.0_04"

RewriteCond User-Agent: .*Java.*
RewriteRule (.*) http\://www.asdf.com/CASP_BotCatch.aspx\?htaccess=1&agentblock=1&ipblock=0 [I,RP]

This worked on my local box, but on the shared box, it does not. I initially tried this:
RewriteCond User-Agent: .*Java.*

RewriteCond %{HTTP_USER_AGENT} (*.Java.*)
RewriteRule (.*) http\://www.asdf.com/CASP_BotCatch.aspx\?htaccess=1&agentblock=1&ipblock=0 [I,RP]

But this did not work on either my local box or my shared host.

Can someone help me out with this? Many thanks

User avatar
Posts: 28
Joined: 02 Mar 2012, 12:50

Re: adding new rule for agent; not working as expected

07 May 2013, 06:36

This rule seems to be correct

RewriteCond User-Agent: .*Java.*
RewriteRule (.*) http\://www.asdf.com/CASP_BotCatch.aspx\?htaccess=1&agentblock=1&ipblock=0 [I,RP]

Please double check that your production server reload config correctly

Try to add simple test rule
RewriteRule testtest - [G]

And request this url twice.

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 1 guest