You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Selmer Ausland <se...@shawcable.com> on 2003/12/11 00:22:53 UTC

[users@httpd] New post, Mod rewrite

Hello Group;

Running Apache 2.0.48
Windows NT 4.0
512 memory

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 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?

This is a copy from my previous post:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://jkcc.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.jkcc.com/.*$ [NC]
RewriteRule
.*\.(gif|GIF|jpg|JPG|mid|MID|wav|WAV|mp3|MP3|avi|AVI|mpeg|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?

Any help would be appreciated, as I really want to prevent these #&*#@#
jerk's robots from accessing my root directory.

Thanks. Selmer Ausland

---------------------------------------------------------------------
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


Re: [users@httpd] New post, Mod rewrite

Posted by "M.D. DeWar" <ma...@s-wit.net>.
www.bignosebird.com has  a cgi script that puts images and stuff into the
error messages.
was easy to setup and somewhat cool.
still have to edit the httpd.conf and other stuff.


----- Original Message ----- 
From: "Selmer Ausland" <se...@shawcable.com>
To: <us...@httpd.apache.org>
Sent: Thursday, December 11, 2003 1:57 PM
Subject: Re: [users@httpd] New post, Mod rewrite




---------------------------------------------------------------------
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


Re: [users@httpd] New post, Mod rewrite

Posted by Selmer Ausland <se...@shawcable.com>.
Robert Andersson wrote:

> The simplest way might be:
> 
>     RewriteRule .* - [F]
> 
> If you want to serve a custom error document, you should do this:
> 
>     RewriteRule .* http://www.mydomain.com/404 [R=404,L]
> 
> Regards,
> Robert Andersson
 
******************************************************************************

Thanks for the assistance Robert. I will play with it and see what
happens. 

Certainly decent of you to offer your help, along with the others who do
the same.
You all deserve a real salute for your efforts!!!!

Selmer

Selmer

---------------------------------------------------------------------
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


Re: [users@httpd] New post, Mod rewrite

Posted by Robert Andersson <ro...@profundis.nu>.
Selmer Ausland wrote:
>     Thanks for your prompt respnse and assistance. Is this what you
> meant?
>
> RewriteRule .*/. http://www.mydomain.com/404 [L,R]

There are several ways you could do it. If you send your front page to the
bots, they will request all links on it, from which they will get the front
page, and might follow them again, etc. Could get nasty!

The simplest way might be:

    RewriteRule .* - [F]

If you want to serve a custom error document, you should do this:

    RewriteRule .* http://www.mydomain.com/404 [R=404,L]

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


Re: [users@httpd] New post, Mod rewrite

Posted by Selmer Ausland <se...@shawcable.com>.
Robert Andersson wrote:

> > 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?

Hi Robert;
    Thanks for your prompt respnse and assistance. Is this what you
meant? 

RewriteRule .*/. http://www.mydomain.com/404 [L,R]

Selmer

---------------------------------------------------------------------
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


Re: [users@httpd] New post, Mod rewrite

Posted by Robert Andersson <ro...@profundis.nu>.
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