Mobile app version of vmapp.org
Login or Join
Si4351233

: How to block a wildcard subdomain in httpd.conf So I am able to block specific subdomains like this: SetEnvIfNoCase Referer knownsub.sorryspammer.com sorryspammer <Location /> Order Allow,Deny

@Si4351233

Posted in: #Apache #HttpdConf

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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Welton855

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 )

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme