Hotlinks Off

I noticed that more and more of the requests to this site are for images that are embedded in somebody else’s pages. That’s quite a drag (as it has caused me almost to lose my other ISP for bandwidth violations until I turned it off).

What to do? Well, wonderful Google helped out.

People that link an image externally to save bandwidth are called bandwidth thieves and their activity is called hotlinking.

To turn their request off, you have to do a little work (nothing tragic). First, you have to turn on mod_rewrite…

After you turned it on by making sure the LoadModule directive is turned on in the httpd.conf, you have to make sure that the Options directive includes FollowSymLinks.

Once that is done, add a .htaccess file to your image directory, and add the following lines into it:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://diva\.homelinux\.org [NC]
RewriteCond %{HTTP_REFERER} !^http://images\.google\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://images\.search\.yahoo\.com [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|bmp|png)$ /images/hotlink.gif [L]

(Of course, you’d use your own site instead of…)

Restart your apache (if you had to change the settings in httpd.conf) and you are done. Don’t forget to put a readable image into /images/hotlink.gif!

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.