Redirect Hotlinked Images

October 7th, 2006

Hotlinking is when people display your files on their websites by referring to them directly rather than taking a copy and hosting them on their own servers. As if using your files without permission wasn’t bad enough, hotlink thieves actually use your bandwidth too.

Hotlinkers could be stealing your bandwidth right now. Have a look through your servers logs and you might spot them.

Fortunately, there’s action you can take to prevent people from hotlinking to your files and some are more comical than others e.g. you could simply refuse to serve the file to any external websites or you could redirect the file request to another file.

I recently discovered some hotlinkers using an image from one of my websites. Their own websites seemed quite legitimate apart from the fact that they were using other people’s images and bandwidth.

To cut these leeches off, I added a few lines of code into my .htaccess file and created an animated image to replace any hotlinked images with. You’re free to do something similar and take a copy of my replacement image for your own use.
Here’s some example code for your .htaccess file. Make sure you change the URLs to your own and not to my copy of hotlinked.gif!

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://internetmarketingfool.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.internetmarketingfool.com/.*$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.internetmarketingfool.com/images/hotlinked.gif [R,NC]

And here’s an alternative image you can use (make sure you upload a copy to your own hosting and not hotlink to mine!):

Of course, you can redirect to any image you want even if it is gay porn! :D

Technorati Tags:

2 Responses to “Redirect Hotlinked Images”

  1. What if you yourself hotlink your own image on another of your own website?
    Anyway to make a list of exception URLs? Thanks.

  2. Sure, Vincent, just copy either line 3 or line 4 and replace my domain with your exceptions.

Leave a reply