Forum Moderators: phranque

Message Too Old, No Replies

mod access string matching

         

l008comm

12:52 pm on Nov 5, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



So related to my other post, I'm trying to block a bunch of user agents in my httpd.conf file. The simpler ones work no problem, but the big one doesn't work:

SetEnvIfNoCase User-Agent "^Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8" bad_bots

That is the exact user agent, but it doesn't match this rule. Do I have to escape out any characters, or anything like that, to make this work?

l008comm

2:13 pm on Nov 5, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



nevermind i figured it out, i did in fact need a lot of \ character escaping.

jdMorgan

2:49 pm on Nov 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The spaces, periods, and parentheses need to be escaped:

SetEnvIfNoCase User-Agent "^Mozilla/5\.0\ \(Windows;\ U;\ Windows\ NT\ 6\.0;\ de;\ rv:1\.8\.1\.8\)\ Gecko/20071008\ Firefox/2\.0\.0\.8" bad_bots

In not escaped, the periods and parentheses are interpreted as regular-expressions tokens, and a space indicates the end of the pattern to the mod_access directive parser.

Jim