Plugin Author
AITpro
(@aitpro)
Nope the slash does not make a difference in this case – it is an assumed slash after .com (or .net, .org, etc) if it does not exist.
Plugin Author
AITpro
(@aitpro)
Hmm the question mark before “mysite” does not need to be there. 😉 And if you have some subdomains you could do something like this.
RewriteCond %{HTTP_REFERER} !^https?://(www\.|subdomain1\.|subdomain2\.)mysite\.com [NC]
Or
RewriteCond %{HTTP_REFERER} !^https?://(www|subdomain1|subdomain2)+\.mysite\.com [NC]
Thank you very much for you response.
Nope the slash does not make a difference in this case - it is an assumed slash after .com (or .net, .org, etc) if it does not exist.
I probably don’t understand and I certainly have no knowledge on this, but aren’t all files that need hotlink protection after that slash (e.g. h**p://mysite.com/wp-content/uploads/2013/01/myimage.jpg) ?
But that’s just a novice rationalization, so you can ignore me.
I don’t have any subdomains and the code works for me. Of course f it can be improved for all, under you criteria, that’s also great. Would happily update to the new version.
Plugin Author
AITpro
(@aitpro)
The condition is based on your domain name and not individual files or file types. So what this rule says is if the Referrer is NOT your website domain then forbid/block that Referrer.
When a visitor visits your website then your website is the Referrer so the visitor will see all of your image files. When another website tries to hotlink to your image files then they are trying to serve those image files on their website domain and their website would be the Referrer/referring website. Since the image files are on your website then the site that is trying to hotlink your images needs to connect to your website to get/display your image files. When they do connect then this .htaccess rule blocks the images from loading/being hotlinked on the website that is trying to hotlink your image files. That is how this rule works.
And the RewriteRule has a .* which means match anything (full path to the image file/name of the image file) and then of course you specify what file types by file extension that are Forbidden/blocked.
RewriteRule .*\.(jpeg|jpg|gif|bmp|png)$ - [F]
Plugin Author
AITpro
(@aitpro)
Question was answered – resolving thread.