Knowledgebase: Hosting FAQ > Tips and Tricks
Stop people from stealing your images ("hot linking")
Posted by Jen Ferraz, Last modified by Jen Ferraz on 11 November 2011 08:33 PM
Is someone linking to images on your site and wasting your data transfer?  This will either stop it, or let you have replce the image they think they're hot-linking to with a custom image of your choice.

Edit the following by replacing "mydomain.com", or just "mydomain" as appropriate, with your actual domain name.  After that, place the text in a file named .htaccess (note the leading dot) and put this .htaccess file in a directory that you want to block the image theft from.  Requests for images from that directory or anything below it will get blocked if the request didn't start from one of your own web pages.  NOTE: You will need slightly different rules if you use a shared SSL certificate on your site; those rules are at the bottom.



RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(http|https)://(www.)?mydomain.com.*$ [NC]
RewriteRule .(gif|jpg)$ - [F]



Instead of blocking the image, if you'd like to show a custom image of your choice instead, here is how you can serve up a different image instead of the one they tried to link to:



RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(http|https)://(www.)?mydomain.com.*$ [NC]
RewriteRule .(gif|jpg)$ http://www.mydomain.com/badimage.gif [R,L]



For Hostasaurus shared SSL customers, choose from the following:

Block Image Theft:



RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?mydomain.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://mydomain.hostasaurus.com.*$ [NC]
RewriteRule .(gif|jpg)$ - [F]



Block Theft & Return Your Own Image:



RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?mydomain.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://mydomain.hostasaurus.com.*$ [NC]
RewriteRule .(gif|jpg)$ http://www.mydomain.com/badimage.gif [R,L]
(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.

Help Desk Software by Kayako support.miva.com/supportsuite/index.php?