Hotlinkers Be Damned

Posted in Geek / Photography by Cujo
November 7th, 2006 - 11:7 PM

So for the past while I removed some info from my .htaccess file which allowed hotlinking of my images to begin again. This was when I was playing with some new plugins for Wordpress and they needed to write to the .htaccess file which in turn didn’t play too nicely with the info I had in there. I removed my added info to get the site working properly and forgot to put it back in.

After a couple of months I noticed a lot of illegitimate hits coming in through my stats which tipped me off that a lot of hotlinking was going on with my images from a variety of different sources.

For those of you who do not know what hotlinking is it is basically when someone links to images (or other types of media) on your site through their own thus using your bandwidth to host the images (or other media). In small doses this doesn’t affect you much but in large amounts with major views on the offending sites your site’s bandwidth can skyrocket (as well as costs) and you end up paying for something that you are not using.

That is my very simple description of the subject; a more detailed one can be found on Wikipedia.

Back to the story.

If you are on your own hosting account and have access to your own .htaccess file it is quite easy to stop sites from hotlinking your images with a few simple lines of code.

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

A lot of that will probably seem like some foreign language or just random keystrokes but it isn’t. The main parts you should be worried with are the “name\.com/” section of the code. By editing this part you can prevent hotlinking from any number of sites. In the above code hotlinking is being blocked from myspace, blogspot and livejournal (I have added others to my blocking). The [NC, OR] after the second and third lines indicate no case (so it doesn’t matter if it was typed myspace or MySpace) and the OR represents or which tells the code to move to the next line (the OR isn’t in the second last line of the code because there are no more options for blocking).

The last line of code tells the script which image to display in place of the hotlinked image. This is where you have the option of some payback or you can do some personal advertising, I took the personal advertising route and any image that is hotlinked from my site displays a banner which has the site’s name/web address listed instead.

For example, a lot of people have been linking to a picture of Fozzie sleeping when he was a puppy. They grab the image location from my site and post that in their blog or where ever, instead of seeing Fozzie they see a banner that says “Better Than Crabs.com”.

For more information on hotlinking check out this page (it is where I initially got the code to use — and the code I used in this post).

I’m okay with people using images from my site however I’d like people to at least acknowledge where they got the image from and give credit to me as the photographer if I was the one who took the photo. I don’t think it’s too much to ask for.

EDIT: Depending on your monitor etc the lines of code may run over and look even more jumbled up.Ã? If they don’t look how they should (or how you think they should) you can see them properly on this site.

Possible Related Posts:
  • No related posts

3 Responses to “Hotlinkers Be Damned”

  1. anita Says:

    Time for another post, Curt! Every time I come here, I see your title–cursing hotlinkers. Cursing people just isn’t nice, and when I read the title, it echoes in my mind as if I’m cursing hotlinkers. I’m sure hotlinkers aren’t nice either, but I don’t want to be guilty of cursing them.

    Why don’t you tell me something nice about a Mac?

    Come spring I’m going to need to figure out some technical stuff and put together a bango presentation for my book launches. I have some old World War II era footage from the US Military I would like to take a clip from, and add it to some sort of slideshow/power point presentation, but at the moment it’s beyond my capabilities, and perhaps that of my Dell.

  2. Cujo Says:

    Sorry Anita, today’s post will be cute and cuddly just for you.

  3. anita Says:

    Thank you, Cujo.