Forum Moderators: open
cyberdyne, if using mod_rewrite you'll need to escape the space as you did in your first post, but leave off the starting anchor:RewriteCond %{HTTP_USER_AGENT} "Slurp\ China" [NC,OR]
Hey keyplr,
that's not correct!
Use of quotes utilizes "exatly as" and includes spaces (or any other character) without requiring escaping of the
space.
Additionally, when using the simgle word China, adding quotes is redundant.
As an aside, you may recall another who came into this forum some time ago and was utilizing quotes on every line because that was the example both provided and expressed in Apache?
It's simply not requried on every line.
Don
The escape however is redundant and not necessary due to use of quotes. (the escape is necessary without the use of quotes)
Your original inquiry included the leading ^ which would not function because the UA does not begin with those terms.
Please don't be confused by this?
It's merely a matter of clarification of practices which help to provide insight into more complicated reg ex. As well as consistency in the usage of pattern for our personal clarification (a solitary error in syntax may and will result in both your htaccess and website (s) from functioning)
RewriteCond %{HTTP_USER_AGENT} "Slurp\ China" [NC,OR]
OR
RewriteCond %{HTTP_USER_AGENT} "Slurp China" [NC,OR]
OR
RewriteCond %{HTTP_USER_AGENT} Slurp\ China [NC,OR]
OR
RewriteCond %{HTTP_USER_AGENT} China [NC,OR]
All three (four; edited to add lone China) above accomplish the same desired effect.
However, I would caution you against not chosing a particular method and then conforming to that method in your practicses.
The result of inconsistency in reg ex amy result in you spending days to determine a syntax error (should you htaccess ever grow large).
keyplr is far more adapt at writing extensive expressions than myself, however I've benefitted from "KISS" in my use of htaccess.
Don
Thanks for correcting me. I hate it when misinformation is posted as valid.
Ever since I started running dual monitors juggling multiple windows
keyplr,
I've a hard enough time keeping track of what comes across one...do the dual monitors affect your ability to focus?
There are occassional days when my eyes or simply out of focus and I'm not able to function with a computer screen.
Don