Forum Moderators: phranque

Message Too Old, No Replies

SetEnvIfNoCase User-Agent "^-$" ban

         

tangor

4:46 am on Jun 29, 2010 (gmt 0)

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



First, will this do what I want?

Second, consequences/opinions if implemented.

wilderness

5:33 am on Jun 29, 2010 (gmt 0)

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



tangor,
I've been using it for a decade, however without the quotes and the NC is unnecessary in this instance.

jdMorgan

3:12 am on Jul 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the intent is to set the environment variable "ban" whenever a client sends a hyphen as a User-Agent string, then the code will do what you want.

We'll assume that you have subsequent code that uses this 'ban' variable to return a 403-forbidden response...

However, be aware that Apache puts a hyphen in the log file when the HTTP User-Agent request header is blank or absent, and this code won't block that case. You'd need a pattern of "^$" to stop blank User-Agent requests, or "^-?$" to stop both hyphen and blank User-Agents.

Blocking blank User-Agent requests isn't a good idea, though, since many legitimate (ISP and corporate) proxies will not send the HTTP User-Agent header. So, for example, blocking blank User-Agents will prevent access to your site by any AOL or EarthLink subscriber, and many corporate visitors as well.

Jim