01 January 2011

How to stop image hotlinking using htaccess

Sometimes it does happen that people use your images using the link of your site. This uses your bandwidth without coming into your notice. In order to prevent this image hotlinking I am sharing a very simple and easy to use code. All you need to do is place the below mention code in your htaccess file and say bye bye to all your worries regarding image hotlinking.
##############STOP HOTLINKING############
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?your-domain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
#########################################

For any queries and problems feel free to comment and don’t forget to replace “your-domain” with the name of your domain in the above code.

No comments: