Am I doing hotlinking protection right?

Discussion in 'Apache' started by Crusader, Jul 9, 2006.

  1. #1
    I've enable hotlinking protection from CPanel, but I just want to check and see if I'm doing it right using the .htaccess file in the root of my domain.

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.mysite\.net
    RewriteRule ^(.*)$ http://www.mysite.net/$1 [QSA,R=301,L]
    RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://seconddomain.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://seconddomain.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://thirddomain.net/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://thirddomain.net$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://images.google.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://images.google.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.images.google.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.images.google.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://images.search.yahoo.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://images.search.yahoo.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.images.search.yahoo.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.images.search.yahoo.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.msn.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.msn.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://msn.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://msn.com$      [NC]
    RewriteRule .*\.(jpg|jpeg)$ http://www.mysite.net/hotlink.jpg [R,NC]
    
    Code (markup):
    The seconddomain and thirddomain are friendly sites I want to allow linking from. I also want to allow Google, MSN etc. The hotlink.jpg should be displayed if someone is hotlinking to a file. Will this work, or did I mess up somewhere?
     
    Crusader, Jul 9, 2006 IP
  2. Crusader

    Crusader Peon

    Messages:
    1,735
    Likes Received:
    104
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Anyone that can help me out here?
     
    Crusader, Jul 11, 2006 IP
  3. sreyas

    sreyas Well-Known Member

    Messages:
    128
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Yes ofcourse this will work. And you could have done easity using hotlink protection section in cpanel. right?
     
    sreyas, Jul 21, 2006 IP