Hotlinking Prevention Through htaccess

Inline linking, also known as hotlinking or leeching, is something all webmasters don’t like. Usually it happens with images. For those who don’t know what is hotlinking: If your image is referred, usually inside IMG tags, on someone else’s website then each time the visitor comes to this site, this image is downloaded from your site, thus stealing your bandwidth (traffic). The fact of using your images without your permission you will not like as well.

You can fix this through .htaccess by disallowing images to load if referrer is not your host and display a “humiliating” image of your choice on the leecher’s site. This technique is well explained here.

But there are more tricky approaches to this problem.

One idea is to redirect HTTP requests for hotlinked images to a Web page giving context to the image. This is done by redirecting requests for images not originating from original site to a “container” Web page, which provides a link to original site and explains that the image is hosted at originalsite.com.


Another approach is watermarking your images. Manually adding a watermark to each image on your site is not practical, especially if you got hundreds of them. This is done through htaccess activated call to a PHP script whenever image is requested. Then PHP script adds a watermark with your logo on each image. Author gives detailed explanation with downloadable package. One thing though you have to do yourself. Script doesn’t check referrer and watermarks images whether you see them from original host or from other referring sites.

I slightly modified PHP script. In my version of watermark PHP script referrer is checked and if the referrer is original host e.g. – your host then script doesn’t put a watermark on images.

This entry was posted in Miscellaneous. Bookmark the permalink.

15 Responses to Hotlinking Prevention Through htaccess

  1. That is cool that people can receive the home loans moreover, this opens up new opportunities.

  2. Hey, I am the first time on this website and am really enthusiastic about so many good articles. I think its simply very good.