As you may have read, a few days ago I found that I was having a few issues with bandwidth theft with people hotlinking to images on my automotive blog without permission. I decided I’d have some fun for a couple of days by replacing the hotlinked images with some non-auto related, border line inappropriate, images.
Yesterday I decided I’d had enough fun and started doing some research into how to prevent hotlinking through editing the htaccess file. I “google’d”, asked questions of people smarter than me, and scratched my head. All the usual stuff. I’d became quite partial to one of my bandwidth thief banners, and wanted to implement a solution that would incorporate the banner somehow.
The solution I settled on (see code below), was to block requests for images from outside sources, and serve up the banner of my choice in place of the actual request.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?domainName\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/bandwidthThief.jpe [L]
In other words, if anyone attempts to hotlink to any images (jpg, gif, bmp, or png) on my server, instead of displaying the requested image, they will instead display my banner of choice.
Simplifying it further, the bandwidth thief thinks they are getting an image of a Subaru WRX STi, but are instead served up a massive set of bulls testicles (see below). I love the internet. If you want to use the “Bull Balls” solution, feel free to copy the image below (NO HOTLINKING!!) 😛 A link back would be appreciated.