How do I stop people hotlinking to images on my avatar site?

Discussion in 'Site & Server Administration' started by AmyNelson, Mar 14, 2006.

  1. #1
    I have seen on some sites, that if you try and hotlink, the image simply appears as 'this image is from xxxxx site' instead.

    How are they doing that, or is there an easier way to prevent it?

    (btw I dont want to have to keep changing the images names every week to prevent it).

    Thanks guys.
     
    AmyNelson, Mar 14, 2006 IP
  2. Smyrl

    Smyrl Tomato Republic Staff

    Messages:
    13,740
    Likes Received:
    1,702
    Best Answers:
    78
    Trophy Points:
    510
    #2
    Go to your control panel and see if there is not an automatic function to block hotlinking? If not you can manually set up your .htaccess file to block. If on an iis server do not know how.

    The image below shows what I find in my control panel. I am not an expert on .htaccess files. If the person hotlinking is coming from a fixed ip add the following to your .htaccess file deny from 123.44.678.90 or whatever the ip is. If they are hitting from a range of ip's look at a .htaccess tutorial for how to deny a range.
     

    Attached Files:

    Smyrl, Mar 14, 2006 IP
    AmyNelson likes this.
  3. AmyNelson

    AmyNelson Peon

    Messages:
    574
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you.
    Could you give me an example as I tried that in the past and it didn't work, but maybe I got the format wrong.
     
    AmyNelson, Mar 14, 2006 IP
  4. Mister Tut

    Mister Tut Guest

    Messages:
    837
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try directing all external image requests to the goatse pic. That's always good for a laugh.
     
    Mister Tut, Mar 14, 2006 IP
  5. Smyrl

    Smyrl Tomato Republic Staff

    Messages:
    13,740
    Likes Received:
    1,702
    Best Answers:
    78
    Trophy Points:
    510
    #5
    Here is the code I am using which is generated by the automatic function provided in control panel

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://yourdomain.com$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.cin$ [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
     
    Smyrl, Mar 14, 2006 IP
  6. AmyNelson

    AmyNelson Peon

    Messages:
    574
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks again. :)
     
    AmyNelson, Mar 14, 2006 IP