Stopping hotlinking

Someone on a Fark thread used one of my pictures of Heather Carolin in an image tag. Then he linked to an different site, could have at least given me some traffic. This is called hot linking and is a bad thing. I served that picture 16000 time this month.

But there is an easy solution which I thought I’d share. You can put an .htaccess in your picture directory and put the following lines in it.

IndexIgnore *
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://reactuate.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.reactuate.com.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp)$ – [F]

Of course replace my domain with yours. The IndexIgnore * line actually just doesn’t allow people to look at the contents of the directory by entering a URL ending in a /. The rest blocks serving of images.

There were a couple of sources for this. First was the Dreamhost knowledge base. Dreamhost is the greatest webhost ever.

Another source was this guide to htaccess. Be proactive and don’t let this happen to you.