Question | Hotlink protection in htacess

Discussion in 'Apache' started by unlisted80, Oct 15, 2006.

  1. #1
    Hi

    I try to protect my site with an htacess hotlink protection

    i try to protect the following
    gif,jpg,png,swf,wmv and mp3

    and here is my code

    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://mydomain.com [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com [NC]
    RewriteRule .*.(gif|jpg|png|swf|wmv|mp3)$ - [NC,F]

    is this a correct way to do it?


    thanks
     
    unlisted80, Oct 15, 2006 IP
  2. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does it work?
     
    penagate, Oct 15, 2006 IP
  3. pulsa

    pulsa Peon

    Messages:
    66
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This worked on my site.
    
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(.+)?mysite.com [NC]
    RewriteCond %{HTTP_REFERER} !^http://(.+)?anotherone.com [NC]
    RewriteRule [^/]+.(gif|jpg|png|swf)$ - [F,NC]
    
    Code (markup):
    The '(.+)?' is for all the subdomains.
     
    pulsa, Oct 17, 2006 IP
  4. unlisted80

    unlisted80 Peon

    Messages:
    644
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks alot
     
    unlisted80, Oct 18, 2006 IP