Disable Hot-Linking of images and other files
by Rekha[ Edit ] 2010-02-09 14:38:49
A hot-linking is when some other site uses images hosted on yours. Hot-linking usually is bandwidth and of course content stealing. The image stealing site will not pay for the traffic used as the image is being loaded from the image containing site.
So it is a good practice to prevent images hot-linking:
You can prevent the hot-linking of your images by creating a .htaccess file with the following content:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?your-domain.com/.*$ [NC]
RewriteRule \.(gif|jpe?g|png)$ - [F]
The above code will result in a broken image to be displayed when it is hot-linked.
The example above works for .gif,.jpg and .png files, but you can add any file extension.
If you place the .htaccess file in the main folder of your site it will disable hotlinking for all your site.
To block other type of files, just add their extension to the list above. For example to block movie files:
RewriteRule \.(mov|avi|wmv|mpe?g)$ - [F]