
Some times one can steal your images by directing URL on your site, it is called image hot linking. In this way others not only steal your images also use your bandwidth. You can stop this in your web servers running Apache’s htaccess file. Follow steps below to stop hot linking for your site
Step 1 – Create .htaccess file
If you’re currently not using any .htaccess in your web server you should now create one in your Documentroot
Step 2 – .htaccess hotlinking code
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?techbabu.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?techbabu.net [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://techbabu.net//hotlink.gif [NC,R,L]
- Line 2 – This Line allows blank referrers
- Line 3, Line 4 ‚Äì Sites allowed to link your images – By default all sites are blocked from hotlinking.
- Line 5 – File format to block, custom blocking images.
You will write file extensions in between the () which you want to block from hotlinking. To add more seperate them with”|”
Also note that some users surf behind the firewalls/gateways etc. and they will not provide any referrers information. Disallowing blank referrers will block them from accessing images of your site. However if you want to block blank referrers, just delete line 2.
Set a image at ‘http://techbabu.net/hotlink.gif‘. Now whenever image hotlinking is attempted, this image will be displayed.
Important Note:
You have to make sure that this image is not hotlink protected otherwise your server can go into an endless loop.
