HotLink Protection Code Not Working Properly

Discussion in 'HTML & Website Design' started by billybw, May 21, 2007.

  1. #1
    Recently I've been having a problem with excessive hotlinking of images from one of my sites. To try to solve the problem, I got the following code from a site called htaccesstools:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?treetrail.net [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.co.uk [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.ca [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?live.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?msn.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?ask.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?aol.com [NC]
    RewriteRule \.(jpg|jpeg|gif)$ http://www.treetrail.net/Hotlink-Substitute-Image.png [NC,R,L]

    In this code the sites after the ? in each line are supposed to be allowed access to the images. treetrail.net is my own site, and google, etc are search engines that I want to allow access for. Any site not included is supposed to be denied access. "Hotlink-Substitute-Image" is a small substitute image I created to send to hotlinkers instead of the image they want.

    The code works to some extent. It denies access to all hotlinkers and it allows access to my own site. But the problem is that it denies access to Google Images (images.google.com), even though Google is on the list.

    So my question is -- How can I allow access to Google Images while keeping everything else the same? Does anyone have a solution?
    Thank you.
     
    billybw, May 21, 2007 IP