.htaccess hot link prevention issues

Discussion in 'Apache' started by mcdeere02, Aug 6, 2009.

Thread Status:
Not open for further replies.
  1. #1
    I have had to implement hot linking prevention on my main site to slow down this problem, but I am now having some problems with allowing the images to show up on some sites. I could really do with some help on this one.

    Here is a section of the .htaccess from the root directory of mysite.com.au (not the real name, nor badimages)

    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com.au/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?maps.google.com.au/.*$ [NC]
    RewriteRule .*\.(jpg¦jpeg¦png)$ http://www.badimages.com/images/bad.gif [R,NC]

    mysite.com.au is the primary site where the images are stored.

    maps.google.com.au and the other google domains are some of the other sites I wish to allow to have hot links working on, but they don't seem to work and just show my warning image.

    See example
    http://maps.google.com.au/maps/ms?ie=UTF8&hl=en&msa=0&msid=116707158377948798030.00044b6e884965fe2ae05&ll=35.811131,140.071564&spn=0.533447,1.056747&z=11

    Then select "Imperial Palace East Garden" to see if the picture shows.
     
    mcdeere02, Aug 6, 2009 IP
  2. pubdomainshost.com

    pubdomainshost.com Peon

    Messages:
    1,277
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try following code

    It would STOP hotlinking only from sites listed below while others would be allowed to link.

    
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]
    
    Code (markup):
    HTH
     
    pubdomainshost.com, Aug 6, 2009 IP
Thread Status:
Not open for further replies.