blocking hotlinking with .htaccess only works for plain domain, when preceeded by www no block
- by casualprogrammer
Having tried all sorts of suggestions popping up from google, I am at my wit's end.
Presently I use a solution created with htaccesstools.com/hotlink-protection/
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.tld/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|png|js|css)$ - [NC,F,L]
Checking it out with altlab.com/htaccess_tutorial.html testing facility (near bottom of page ) shows no image if mydomain.tld/mypic.jpg is entered, while if prefixed with www (www.mydomain.tld/mypic.jpg) the pic is displayed.
Any helpful comments welcome.