Forum Moderators: phranque

Message Too Old, No Replies

RewriteCond and Capitalization

         

pendanticist

5:53 am on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An uppercase Dumbot missed my Rewrite.

What I have...

RewriteCond %{HTTP_USER_AGENT} DTS\ Agent [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^dumbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]

What came calling...

141.156.39.** - - [04/Jan/2004:16:10:11 -0800] "GET /Blah_Blah.html HTTP/1.0" 200 13835 "-" "Dumbot(version 0.1 beta)"

What should keep it away...

RewriteCond %{HTTP_USER_AGENT} DTS\ Agent [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^dumbot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]

Is this correct to catch the uppercase Dumbot too? I'm admittedly tired, but I do recall there is a certain circumstance here that I'm not sure about. I just can't remember what that was.

Thanks.

jdMorgan

6:15 am on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



pendanticist,

The [NC] flag means that the string comparison will be made without any regard for uppercase/lowercase.

Therefore, "RewriteCond %{HTTP_USER_AGENT} ^dumbot [NC]" will match "dumbot", "DUMBOT", "DuMbOt", or any other combination of letter capitalizations. Neither the case of the actual user agent, nor the case of the pattern in the RewriteCond matters when [NC] is used.

For practical purposes, you can assume that mod_rewrite converts both strings to all-uppercase (or to all-lowercase, it doesn't matter, really) *before* it compares them.

Jim

pendanticist

6:36 am on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes! That's the part I couldn't remember Jim. ;o

I was kinda in the right Church, but the wrong Pew.

Thanks.

Nappy time.