Hi everyone, I have recently had number of websites that link directly to images from my website. This is not hotlinking, it is direct server request. As an example: on the linking website there is image gallery script with thumbnails and when the visitor clicks on the thumb it calls the image from my website. I block their IP-s in .htaccess, but it is not the best way to stop them since IP change. Is there any way, similar to anti-hotlinking, to deny such direct access to my images by domain name i.e. to allow only from my website and deny from all others. Or something else that could work in my case with .htaccess. your help is greatly appreciated, georgi
Many years ago, when I had a person blog, I wrote a few articles on blocking image leechers about a few methods, such as .htaccess, custom php scripts (and even combining them). I think what you want is this: RewriteEngine on RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC] RewriteRule \.(jpg|jpeg|png|gif|tif|bmp)$ - [NC,F,L] Code (markup): Obviously, replacing google.com with your sites name. That's just a guess (I haven't tested it as I'm at work).
You wrote, "to allow only from my website and deny from all others". So, you just need to add a line for Google, Yahoo, Bing, etc, such as: RewriteCond %{HTTP_REFERER} !google\. [NC] Code (markup): Is the simplest way. (Rather than what I originally wrote due to all the different ccTLDs for Google.)
yes. you are right. and what about regular anti-hotlinking? i also have it in .htaccess. are all hotlinking sites also be blocked in this case? thank you for your help
I don't know what you mean by regular anti-hotlinking. The above won't allow blank referrers and only allow your own site and Google as the referring sites.
this is what i have now as hotlinking protection RewriteEngine On RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC] RewriteCond %{HTTP_REFERER} !^http://(.+\.)?bing\.com/ [NC] RewriteCond %{HTTP_REFERER} !^http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/translate_c [NC] RewriteCond %{HTTP_REFERER} !^http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/search [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://mysite.com/hotlink.jpg [L] Code (markup):
Write. Personally, I would just deny them altogether, rather than redirecting to another image. It's all anti-hotlinking, just personal preference on how it's done. Use whichever method you prefer.