Forum Moderators: phranque
i'm getting this agent in my logs and want to stop it.
access_log fragment:
68.97.85.241 - - [02/Jan/2003:20:23:19 +0000] "GET / HTTP/1.1" 200 16353 "-" "Mozilla/4.0 (compatible; grub-client-1.0.6; Crawl your own stuff with [grub.org)"...]
213.51.142.55 - - [03/Jan/2003:05:10:32 +0000] "GET /index.html HTTP/1.1" 200 16360 "-" "Mozilla/4.0 (compatible; grub-client-1.0.6; Crawl your own stuff with [grub.org)"...]
.htaccess fragment:
RewriteCond %{HTTP_USER_AGENT} ^grub [OR]
etc etc
why doesn't this work?
thanks in advance...
RewriteCond %{HTTP_USER_AGENT} ^grub [OR]
etc etcwhy doesn't this work?
It doesn't work because the user agent does not begin with "grub", it begins with "Mozilla". The start anchor "^" means the pattern should match anything starting with "grub".
In order to block "Mozilla/4.0 (compatible; grub-client-1.0.6; Crawl your own stuff with [grub.org)"...]
You could use:
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ \(compatible\;\ grub [OR]
RewriteCond %{HTTP_USER_AGENT} grub [OR]
Here's a concise Regular Expressions tutorial [etext.lib.virginia.edu] for more info.
HTH,
Jim
After the brushup on regex start and end anchors, you may want to check through your block list and make sure it's doing what you expect - those stray anchors can mess things up. If you know the user agent starts and/or ends with a particular string, use the anchors - they can speed up the compare measurably. If not, leave them off until you've actually caught a sample, then refine the pattern and add anchors for a more efficient match.
For those who haven't seen it yet, one of our forum hosts, DaveAtIFG, did a bang-up job on this Introduction to mod_rewrite [webmasterworld.com].
Jim