Project

General

Profile

[Solved] disable hotlinking for specific domains

Added by rocky123 almost 8 years ago

hi,

i disabled hotlinking on my server for one specific folder /i/

$HTTP["referer"] !~ "^($|https?://(.*\.)?domain1\.com|https?://(.*\.)?domain2\.com|https?://(.*\.)?domain3\.com|https?://(.*\.)?domain4\.com|https?://(.*\.)?domain5\.com|https?://(.*\.)?domain6\.com)" {
url.redirect = ("^/i/(.*)\.(jpg|gif|png)" =>
"http://domain.com/error.jpg")
}

now i have another folder /h/ where hotlinking is working there i want to disable hotlinking only from some specific domains, it should work for rest of websites on internet.

note:- not enable from specific domains like i did on /i/ folder but disable hotlinking for specific domains in /h/ folder.


Replies (3)

RE: disable hotlinking for specific domains - Added by gstrauss almost 8 years ago

Your question is unclear, given that you have already provided a solution above. Just change the !~ condition to =~ for the referer domains you wish to block. If the "from specific domains" is not in the referer, the please specify how you are determining those "specific domains" origin. What info are you using to obtain that info? $SERVER["socket"]?

RE: disable hotlinking for specific domains - Added by rocky123 almost 8 years ago

above solution is to ALLOW hotlinking to only from domain1.com domain2.com domain3.com domain4.com domain5.com domain6.com for content in folder /i/

not i want solution to DENY hotlinking from only domain7.com for content in folder /h/

i have solution to allow but i need solution to deny.

RE: disable hotlinking for specific domains - Added by gstrauss almost 8 years ago

Yes, as I said above, use =~ instead of !~

$HTTP["referer"] =~ "^https?://(.*\.)?domain7\.com" {
    url.redirect = ("^/h/(.*)\.(jpg|gif|png)" => "http://domain.com/error.jpg")
}

    (1-3/3)