.htaccess To Stop Hot linking help...

Discussion in 'OT Technology' started by MiNu3, Dec 29, 2004.

  1. MiNu3

    MiNu3 New Member

    Joined:
    Jul 13, 2004
    Messages:
    1,328
    Likes Received:
    0
    Location:
    St.Louis
    ok i have the .htaccess into the directory that i want to protect from hotlinking but now i cant even get to the page with the link on my page and my website is suppost to be allowed too.. if anyone could help or suggest anything that would be great thanks.

    my code looks like this

    Rewriteengine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [NC]
    RewriteRule .*\.(gif|GIF|jpg|JPG|mp3|MP3)$ - [F]

    mysite has my sites name inplace of it
     
  2. Hezkezl

    Hezkezl Rawr! OT Supporter

    Joined:
    Apr 26, 2004
    Messages:
    38,727
    Likes Received:
    31
    Location:
    Nowhereville
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg)$ - [F]
    
    Be sure to replace "mydomain.com" with your own. The above code causes a broken image to be displayed when its hot linked.

    If you're feeling bitter, you can set things up so an alternate image is displayed in place of the hot linked one. The code for this is:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg)$ [url]http://www.mydomain.com/nasty.gif[/url] [R,L]
    
    Same deal- replace mydomain.com with your own, plus nasty.gif.

    Close, but not quite. you need the http://(www\.)?mydomain.com part :p
     
  3. MiNu3

    MiNu3 New Member

    Joined:
    Jul 13, 2004
    Messages:
    1,328
    Likes Received:
    0
    Location:
    St.Louis
    alrite I have replaced mydomain with my domain name and when i put it in the directory, it wont even allow me to click the link on through my site. I get the forbidden error...
     

Share This Page