2

So I am able to block specific subdomains like this:

SetEnvIfNoCase Referer knownsub\.sorryspammer\.com sorryspammer

<Location />
Order Allow,Deny
Allow from all
Deny from env=sorryspammer
</Location>

which does successfully block visits to any site on my server that come from the referrer, knownsub.sorryspammer.com

So now, I am getting visits from referrers like 1.sorryspammer.com, 2.sorryspammer.com, 8.sorryspammer.com, 22.sorryspammer.com, etc., and I need to set an environment variable to block any subdomain coming from the referrer domain sorryspammer.com.

I know I need to set the same basic rule for the environment variable but with a wildcard for the subdomain part. I've tried a couple of things, most recently this:

 SetEnvIfNoCase Referer (.*)\.sorryspammer\.com sorryspammer

but I am still getting visits from referrers from subdomains on sorryspammer.com. I know I'm missing something real simple. Not sure if it matters, but keep in mind that this is not going in an .htaccess file but is going in the httpd.conf file to apply the rules server wide.

1

the example you provide should and does work (tested on 2.2). so I guess the problem will be somewhere else.

your env may be getting an another value somewhere else?

(note the regexp will not match plain 'sorryspammer.com' - you need something like ^(.*\.)?sorryspammer\.com$

note2: you could use .*sorryspammer, but that is bad practice, since it matches also things you didn't specify first - othersorryspammer.com, sorryspammer.comexample.org )

| improve this answer | |
  • Thanks. I did try with your Regex too and for some reason, anything.sorryspammer.com is still getting through. Seems like both Regex examples should work. I do have several other env rules, but any env rule will trigger the blocking of the referrer so even if it did somehow pick up another env value, it seems like the referrer would be blocked anyway. Your answer is heplful and I appreciate it. I'm just perplexed why it is not working. – Bogarto Jul 3 '14 at 14:49
  • Actually it would seem that your answer is correct (that my original code should and does work). :) I just tried my original code and it is now blocking unwanted subdomains from sorryspammer. I may have had an error in my syntax when I tried originally. Thank you for taking the time to answer my question. – Bogarto Jul 3 '14 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.