Blog » Blocking Hotlinking of Images by Other Websites

Blocking Hotlinking of Images by Other Websites

There have been several cases of external websites embedding images from this website directly into their pages. Known as hotlinking, this results in bandwidth being used up on this website, for the traffic belonging to another website. Hotlinking is essentially stealing of bandwidth from another website, which someone else (or me, in the case of this website) has to pay for. Up until now I have been fairly relaxed about this, after all, some of these external pages were discussing projects on this website and providing inbound links. However, I have also had totally non-related websites hotlinking websites. Most recently, a classified listing on another website was using a photo of my old Compaq Presario in order to sell their item. Not only is this non-related traffic, but the photo shown in the advertisement was most certainly not of the item being sold; something that could be misleading to prospective buyers (it's clearly not a company promotional shot, so the assumption would be that it is the second hand item being sold). With this latest incident I decided that I was fed up with others stealing my bandwidth for non-related websites, and any page that hotlinks to this website now shows the following image:

No hotlinking

How to Block Hotlinking

There are various methods with which hotlinking can be blocked, but the method that I used was to add this to the end of the .htaccess file for this website (below the Silverstripe URL rewriting):

# Block image hotlinking
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?hdrlab.org.nz [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlinking.png [L]

This works by examining which webpage the file request was linked from (i.e., the referer), and redirecting any image request for which the referer is not this website (or unknown) to the image shown above. Note that "RewriteEngine On" must appear in the .htaccess before the code above, or it will do nothing. Anyone using this code should replace "hdrlab.org.nz" with their own website's URL.

What's Wrong with Hotlinking?

Some people would argue that there is nothing wrong with hotlinking. Their claim is that, since the website owner has made it publicly available, people should be able to do what they wish with it. This is not the case. What appears on one website can be copyrighted content that may not be used on another website without permission. However, this is not the real issue, the real issue is who pays for the bandwidth resulting from website traffic.

Let us say that I owned a website with millions of visitors per month, and I hotlinked an image from your small website with a 1 GiB/month allowance and placed it on the home-page. All of a sudden your website would receive millions of downloads of that image, which, not being a small file, this promptly exceeds your bandwidth limit, which either takes your website offline, or gives you a hefty bill for extra bandwidth charges. Clearly this is unfair; you should not have to pay for the bandwidth of visitors to my website, or any other website for that matter.

This is why websites should either obtain permission to host the image themselves (which they should be doing anyway, regardless), or posting a link to the website containing the image so that it can be viewed within the original website. In a previous argument about this topic, someone pointed out that an external website posting a link to my website would result in even more of my site's bandwidth being used up than if they just hotlinked the image. True, however this bandwidth would be due to people visiting my website, as opposed to visitors of the other website. I would be quite happy to pay for extra bandwidth if this website had a huge influx of visitors; hopefully the advertisements shown to these visitors would cover the extra costs, or at least offset them. What I am not okay with is paying for another website's traffic.

Watermarking Images - An Alternative to Blocking

If bandwidth is not an issue for you, but you object to the lack of acknowledgement when someone hotlinks an image, another option could be to insert a watermark into hotlinked images. That way, your logo and URL could appear in the image itself whenever it is hotlinked. I personally opted for blocking and placing this website's logo and URL into the redirected image; I do want to discourage hotlinking.



Blog » Blocking Hotlinking of Images by Other Websites

Post your comment

Comments

  • This is a nice blog. Good clean UI and nice informative blog. I will be coming back soon, thanks for the great blog. I put a link to your blog at my site, hope you don't mind?

    Posted by http://www.listfortmcmurray.com, 27/08/2012 2:02am (5 years ago)

  • @compliance-training

    The theme is a customised version of a theme called "higherground," which you can find at: http://www.silverstripe.org/higherground/

    Posted by Hans, 14/02/2012 7:55pm (5 years ago)

  • I really enjoy this theme you've got going on in your web page. What is the name of the template by the way? I was thinking of using this style for the site I am going to construct for my school project.

    Posted by compliance training, 14/02/2012 7:23am (5 years ago)

  • hotlinking should must be blocked for a beter performance . and the steps expressed in the above article are best to do so.

    Posted by personal injury Ireland, 02/12/2011 9:53am (5 years ago)

  • @brachial plexus injuries

    Yes, an external website posting a link to my site does use up more bandwidth than if they hotlinked an image. However, that bandwidth is the result from people actually visiting my website. So, that bandwidth is of value. With hotlinked images, the bandwidth used up is for visitors to someone else's website. These people never visit or see my website, and so that bandwidth is of no value to me; it is wasted, leached bandwidth.

    In conclusion, the goal is not to prevent bandwidth from being used, but to keep it for those who actually visit my website.

    Posted by Hans, 21/11/2011 1:23pm (5 years ago)

  • In a previous argument about this topic, someone pointed out that an external website posting a link to my website would result in even more of my site's bandwidth being used up than if they just hotlinked the image.

    Posted by brachial plexus injuries, 20/11/2011 2:03pm (5 years ago)

  • Excellent read, I just passed this onto a colleague who was doing a little research on that. :D

    Posted by Steroids, 03/12/2010 9:13am (6 years ago)

  • Hi Polprav,

    Yes, quoting from a post in this blog is fine if you link back.

    regards,
    Hans

    Posted by Hans, 18/10/2009 3:40pm (8 years ago)

  • Hello from Russia!
    Can I quote a post in your blog with the link to you?

    Posted by Polprav, 16/10/2009 3:36pm (8 years ago)

RSS feed for comments on this page | RSS feed for all comments


Blog » Blocking Hotlinking of Images by Other Websites