What is the best way to protect images from hotlinking? And not just images, but maybe the entire site? I have a forum that a lot of people have uploaded images to. So I would like to protect the images directory from anyone trying to hotlink to the files. The directory index is protected by a blank index.html file. But if someone knows the url to the image, it can be hotlinked.
When I activated hotlink protection through cpanel, there was some kind of error about an .htaccess in the apache directory and the site crashed with an Internal Server Error message. So I had to disable hotlink protection to get the site back online. I submitted a ticket to support for them to look into the problem. But until I get a reply from them, I would like to know what my other options are.
You can directly block it using .htaccess file. Just create a code from below link: http://www.htaccesstools.com/hotlink-protection/ And add this to your .htaccess file. Kailash
You can directly generate it using .htaccess file. Just create a code from below link: http://www.htmlbasix.com/disablehotlinking.shtml but my problem is that Thumbnail also get hotlink protected. How to avoid this? RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?exbii.com(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.com(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?gmail.com(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?masti.s4.bizhat.com(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?dadesiforum.com(/)?.*$ [NC] RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://i43.tinypic.com/2ennhj7.jpg [R,NC] Code (markup):
Check your Apache logs for sites that are hotlinking. Change the images on your own site every now and then and change the old images to something mean. That way the other webmasters won't mess with you again.
This might sound like a good idea, but I have a forum and my members have uploaded thousands of images. It would be almost impossible to edit the image name, then go back to the thread where the image is at and then edit the post. I tried the .htaccess file suggestion, but it seems that some of my members, their isp might use a caching server. Because several members were not able to see the images, not even the post reply button or avatar.
I have heard of this program, not sure if it is any good or not for your needs: http://www.helicontech.com/hotlinkblocker/
Look in your logs for referrer headers. If the image has a referrer header that isn't from your own site then it is being hotlinked. If you visit the site you could ask their webmaster to stop. If you really wanted to you could create a script that displays a different image for that domain if it is found in the referrer.