Forum Moderators: open

Message Too Old, No Replies

How do you block requests with no UA

Would this work?

         

Kerrin

11:05 am on Mar 4, 2003 (gmt 0)

10+ Year Member



I've been seeing an increase of abuse from requests with no User Agent. Is this the correct syntax to block them?

...
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
...

wilderness

11:58 am on Mar 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Kerrin,
I've been using the following for some time. Somebody provided another recently although the threads on a search were too numerous to go through.

RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteRule ^.*$ [F]

Kerrin

1:54 pm on Mar 4, 2003 (gmt 0)

10+ Year Member



Thanks Wilderness. I eventually found this page: [webmasterworld.com...]
It looks like the following should work:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
...
RewriteCond %{HTTP_USER_AGENT} ^.*[Ee]mail
RewriteRule ^.* - [F]

carfac

6:42 pm on Mar 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Kerrin:

Wildereness' version is better. His will block totally blank OR one that has "-" as a US (which is much more common!) Yours will only block TOTATLY blank UA's, which is rare.

Go with the "^-?$" expression!

jdMorgan, PLEASE correct me id I read that wrong...

carfac

6:43 pm on Mar 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, and in cace you care, the other line: RewriteCond %{HTTP_USER_AGENT} ^.*[Ee]mail can be written like this, too:

RewriteCond %{HTTP_USER_AGENT} ^.*email [NC]

wilderness

7:32 pm on Mar 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<snip>Wildereness' version is better</snip>

Actually Cardac it taint my version :(
I likely copied it from somebody here or someplace else when I first started with htaccess.

Don

carfac

12:25 am on Mar 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wilderness:

<snip>I likely copied it from somebody here...</snip>

Don't we all? I have taken a FEW of your notices on this board and added them to my lists! Like Jim said in a different trhread, you have a good eye for this! So (since I haven't said anything yet) Thanks for posting all those devils you find!

dave

wilderness

1:29 am on Mar 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<snip>Don't we all? I have taken a FEW of your</snip>

Dang! Didn't you read the copyright notice on ALL my board submissions ;)

Kerrin

6:07 pm on Mar 5, 2003 (gmt 0)

10+ Year Member



Thanks everyone, much appreciated

Kerrin

carfac

7:53 pm on Mar 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<snip>Didn't you read the copyright notice on ALL my board submissions </snip>

Yes, I did.... and your copyright notice is intact on my server. Go ahead, stumble into one of my spider traps.... you will get a notice that says:

"Thank you for visiting mydomain.com. I am sorry, wilderness says you are a leech of my resources. Get out now."