Learn about web site design and development, affilite programs, SEO, search engines, Google, and more.

How to Stop Image Hotlinking

Hotlinking in simplified terms is linking to a graphic on another persons website without permission. How does it happen? Usually someone visits your website. They “like” a graphic that they’ve seen on your web site and decide they want it on their website. I guess you should be flattered. This person doesn’t bother to ask you for permission to use the image or even right click on the graphic to steal the graphic outright. Maybe they are an inexperienced novice or maybe they just don’t care. Instead they opt to link to the graphic from their website using a code similar to the one below:

<img src=”http://www.victimsite .com/image_name.jpg” height=”89″ width=”53″>

Sounds harmless, right? Well, not really.

code to stop image hotlinkingFirst let me explain to you about bandwidth. Bandwidth is the total amount of resources that are used by a web site. Bandwidth is calculated in bytes of data downloaded from your web site visitors and includes pages, images, files, etc. Every time a visitor comes to your web site and opens a page, this uses up your bandwidth.  Most web hosting plans come with a certain amount of bandwidth that you are allotted to each month. When someone is hotlinking to your graphics, each time their page is loaded with your graphic it goes against your web site’s bandwidth. This could cause you to run out to run out of bandwidth and have to purchase additional bandwidth to keep your website online. In essence, you have to foot the bill for this person who stole your graphics and who caused you to run over your bandwidth allotment for the month. Not Cool. If a lot of people hotlink to your graphics you’re going to have a big EXPENSIVE problem!

Besides putting notices on your website to prevent hotlinking, you can add the following to your .htacess file:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.hooverwebdesign.com [NC]
RewriteCond %{HTTP_REFERER} !^http://hooverwebdesign.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www.photos.hooverwebdesign.com [NC]
RewriteCond %{HTTP_REFERER} !^http://photos.hooverwebdesign.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www.google.com [NC]
RewriteCond %{HTTP_REFERER} !^http://google.com [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|swf|SWF|zip|ZIP|wav|WAV)$ http://www.hooverwebdesign.com [R,L]

Instead of the hooverwebdesign domain, add your domain there with and without the www. If you have any subdomains on your website list them with and without the www. You can also list any other domains that you want to be able to access to your graphics.

Using this server rewrite code will only allow the domains listed in the .htaccess file to show your images from that web site.  All other websites who try to display your images will show broken links. When the hotlinking thief pulls up his website and sees the broken images they’ll usually delete the links to your images and find someone else to steal from.

Here is a link to an additional article which discuss more ways to stop image hotlinking:

David Airey Blog  (you have to scroll down a bit to read the post)

I hope this helps.


Content © 2008 Hoover Web Design http://www.hooverwebdesign.com

May 17th, 2008 at 12:54 pm

One Response to “How to Stop Image Hotlinking”

  1. David Airey Says:

    Hi Gina,

    Thanks very much for the kind mention. I appreciate it.

Leave a Reply

Note, all comments are moderated. If you do not see your comment, please be patient as the admin has to approve it before it is posted on this website. Spam comments are not posted. Thank you.

Hoover Web Design.

You must be logged in to post a comment.