Wednesday, February 10, 2010

Protect your images from HotLinking

Have you ever wonder why there is so much bandwidth you have on your invoice from web hosting companies? Then, someone leeched your images for their own personal use. This is what we call hotlinking or leeching. Wikipedia defines this as the use of a linked object, often an image, from one site into a web page belonging to a second site. The second site is said to have an hot linked to the site where the object is located. To stop users from hotlinking, upload an .htaccess file to the root of your site directory and copy this code.

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?your_domain_name.com/ [nc]
RewriteRule .*.(png|gif|jpg|jpeg)$ http://domainname.com/img/hot_link_image.png [nc]

Take note this will only work on linux servers.

No comments:

Post a Comment