Forum Moderators: phranque

Message Too Old, No Replies

How to block hot-linking on all sub domains

by htaccess

         

jetteroheller

2:08 pm on Aug 21, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I just have now

RewriteCond %{HTTP_REFERER} ^http://(.+\.)?example\.com/ [NC]
RewriteRule .^(.*)$ http://cgi.example.com/nospamers.png [L]

but this does not work at subdomains.

How to change the line,
that also all subdomains are blocked?

It's an extreme referer spamer showing up also on Google Analytics.

lucy24

3:25 pm on Aug 21, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If it doesn't work with subdomains, the rule is located in the wrong place. But from your example it's impossible to tell whether the rewrites, as a whole, are just in the wrong htaccess file / wrong directory, or whether they're too far down the mod_rewrite list, after requests for subdomains have already been intercepted.

Since you've got an [L] functioning as an access-control rule (much like the common anti-hotlinking functions), you need to place it together with any RewriteRules that end in the [F] flag.

Incidentally you don't need the full
^http://(.+\.)?example\.com
(an awful format anyway, since it initially matches ALL referers) All you need is
semalt\.com
without opening anchor.

Edit: Yup, we all know semalt. My own rule uses mod_setenvif so it can be shared by all domains using the same htaccess.

[edited by: Ocean10000 at 6:54 pm (utc) on Aug 24, 2014]
[edit reason] Fixed Typo [/edit]

jetteroheller

8:55 am on Aug 24, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



semalt\.com

only blocks ony semalt.com but not
55.semalt.com

How can I block all subdomains of semalt.com?

wilderness

11:48 am on Aug 24, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



SetEnvIfNoCase Referer semalt keep_out

or

RewriteCond %{HTTP_REFERER} semalt

lucy24

6:32 pm on Aug 24, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How can I block all subdomains of semalt.com?

By saying
semalt\.com
without opening anchor