One of the first things I did when I decided to start working on a blog was to look at the etiquette of the blogosphere. It seems that one of the biggest no–nos is to steal other people‘s bandwidth by hot–linking images.
Well, I‘ve posted some images on here, which are not my work. I‘ve gone to the bother of hosting them so as not to transgress, I certainly don‘t want to piss off other bloggers, by breaking with etiquette. Also, bandwidth costs money, so it makes sense that it is frowned upon.
That hasn‘t stopped people from hot–linking images that I am hosting, this one in particular. So I decided to do something about it.
I have significant experience of configuring Apache and mod_rewrite so I could have rolled my own solution. I'm not one for re–inventing a wheel that has already been invented a million times however. The best article I could find that details how hot–linking can be tackled using Apache is this one at A List Apart, which as a great site for web–professionals.
In that article, the solution actually results in broken images on any pages on “unauthorised” sites. My solution is much the same but slightly different in that it renders an alternative image. Mine is a shameless promotion of my software development skills, though probably not my design capabilities.
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !malethan\.com [NC]
RewriteCond %{HTTP_REFERER} !www.malethan\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /images/some_replacement_image.png
First published on Mar 21, 2009. Last updated on: Mar 21, 2009.