views:

43

answers:

1

I have several sites listed in my htaccess file that I want banned but apparently, they are not being matched. I'm wondering if someone can tell me what I'm doing wrong. I have seen many tuts and all of them differ in one way or another so there is no way for me to know which way is the correct way.

This is the condition (one of them) in my htaccess file

RewriteCond %{HTTP_REFERER} ^as13448.com\.com [NC,OR]

This was in the log

static-208-80-193-32.as13448.com

What am I doing wrong here?

+5  A: 

The ^ is an anchor, it only matches if the string starts with as13448.com.

You also seem to have the .com part double.

Jimmy Shelter
Thanks Jimmy. I didn't even notice that.
jim
Hey Jimmy, are there any good resources you can suggest for beginners? I actually like regex but need to learn a bit more.
jim
Well, the `.com` part isn't doubled; in the first instance the dot isn't escaped, therefore matching any character.
Joey
Should the dots always be escaped? I have seen a few other examples where they were not escaped.
jim
I'm not Jimmy, but I found this site: <http://www.zytrax.com/tech/web/regex.htm> which explains RegExps especially for Apache. You're best off learning the exactly appropriate one because regexp implementations differ in annoying little details.
Carl Smotricz
A non-escaped dot *will* match a dot, but it will also match any other character! So it will work, sort of. That's why people often get away with forgetting to escape it.
Carl Smotricz
Thanks for the link and the explanation Carl. I'll have a look at that link now.
jim
If dots are not escaped they mean any character (except newline).If you are starting to learn regular expressions I recommend you try reading http://www.regular-expressions.info/ and try testing them in either something like Perl or a simple interpreted language so you can better see what is going on.
ternaryOperator
Hey Carl, thanks! That **is** a fantastic link.
jim
I know PHP so I can use preg_match for that. Thanks ternary..
jim