Hotlinking

Using .htaccess To Stop Hotlinking

Recently, a few of my photos started ranking highly on Google Image Search for terms like "cat" or "geese". An unfortunate side effect of this new found popularity has been dozens of people hotlinking my images on their websites without permission.

At first, I didn't really mind, but it reached a point where 9 out of 10 hits on my website were for hotlinked images. So I decided I had to do something about it.

The solution was to write an .htaccess file to block hotlinks, and place it in my photos directory. The code looks something like this:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?blamcast.net [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?ppalinks.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?drupal.org [NC]
RewriteRule \.(jpeg|jpg|gif|png)$ http://example.org/bad.jpg [NC,R,L]

... Read the rest of this post!

Posted by John on 2007-11-02
Syndicate content