httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Andersson" <rob...@profundis.nu>
Subject Re: [users@httpd] New post, Mod rewrite
Date Thu, 11 Dec 2003 05:55:10 GMT
Selmer Ausland wrote:
> I would like to use Mod Rewrite to ban bad bots from my root directory.
> Below is an example of what I have in mind.
>
> RewriteEngine On
> RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR,NC]
> RewriteCond %{HTTP_USER_AGENT} ^Bot\mailto:craftbot@yahoo.com [OR,NC]
> RewriteRule /*$ http://www.mydomain.com [L,R]

I think that rule could use some modification; the pattern doesn't make much
sense. You probably just want ".*". Are you sure you want to redirect them
back to what I assume is your front, rather than sending them some error?

> I would like to place this in the body of my Apache httpd conf file
> rather than in the individual VH and Directories. (I assume this is
> permissable from what I have read in the docs.)
>
> The question is; will this conflict with the current use of mod rewrite
> that I am using to prevent linking to my .gifs .jpgs .mid, that is also
> located in the body of my Apache httpd conf?

No, no conflict, but you won't need "RewriteEngine On" on both.

> This is a copy from my previous post:
> ...snip...
> RewriteRule
> .*\.(gif|GIF|jpg|JPG|mid|MID|wav|WAV|mp3|MP3|avi|AVI|mpeg|MPEG)$
> - [NC,F]

No need to include lower and uppercase versions of each extension in the
pattern, as you're using the NC flag. It wouldn't help much either as you
run on Windows, and thus the offenders could use URIs such as
"something.jPg" to get around it. You don't need the leading ".*" either, it
will just slow down pattern matching. Just have it as:

    RewriteRule \.(gif|jpg|mid|wav|mp3|avi|mpeg)$ - [NC,F]

> Finally, is there any particular section in the main body of the Apache
> httpd conf that these rewrite rules should be placed?

You can probably put it anywhere after mod_rewrite is loaded, but I'd put it
just above the VH section. Just a matter of taste.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message