1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using Mod ReWrite to Prevent Hotlinking

Discussion in 'Apache' started by yfs1, Sep 5, 2005.

  1. #1
    So like most, I have issues with people using my images but being to lazy to do a right click...Save as.

    So I have added a Mod ReWrite to my htaccess:

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com(/)?.*$     [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?forums.mysite.com(/)?.*$     [NC]
    RewriteRule .*\.(gif|jpg|jpeg|bmp)$ - [F,NC]
    Code (markup):
    Is there a downside to this? I don't care about Google Images as its not a site that can benefit from that.

    Cheers
     
    yfs1, Sep 5, 2005 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Froogle and other shopfeeds should be allowed too if applicable. Though some store their own thumbnail.
     
    T0PS3O, Sep 5, 2005 IP
  3. yfs1

    yfs1 User Title Not Found

    Messages:
    13,798
    Likes Received:
    922
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I also just added an image so it doesn't come back 404

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com(/)?.*$     [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?forums.mysite.com(/)?.*$     [NC]
    RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://www.mysite.com/image-not-available.jpe [R,NC]
    Code (markup):
    I don't use Froogle (Never get a response back) so it shouldnt be an issue. I will keep that in mind if I go that route though
     
    yfs1, Sep 5, 2005 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hmmm Froogle gives me loads of sales. Anyway, a lot of sites use that script so shouldn't be any issues.

    BTW what's the easiest way to detect hotlinking?
     
    T0PS3O, Sep 5, 2005 IP
  5. yfs1

    yfs1 User Title Not Found

    Messages:
    13,798
    Likes Received:
    922
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I found it in my logs. I would be interested in a tool that checked for it automatically although I haven't seen anything
     
    yfs1, Sep 5, 2005 IP
  6. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I do the same, except I allow google images and all the various other image searches as I get most of my hits from those.

    I use a nice image with the url of the site to show instead and I think that gives me quite a few hits too.
     
    blinxdk, Sep 5, 2005 IP
  7. hulkster

    hulkster Peon

    Messages:
    1,705
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Keep in mind that some browsers allow you to disable referrers ... so for those surfers, they won't be able to see your images ... I don't think there is any "good" solution to this problem short of somehow checking to see if the same dude just loaded the referencing HTML file ....
     
    hulkster, Sep 7, 2005 IP
  8. Roman

    Roman Buffalo Tamerâ„¢

    Messages:
    6,217
    Likes Received:
    592
    Best Answers:
    0
    Trophy Points:
    310
    #8
    If your provider has cPanel there is a link: 'HotLink Protection' to protect against remote linking.
     
    Roman, Sep 7, 2005 IP
  9. hulkster

    hulkster Peon

    Messages:
    1,705
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Correct me if I'm mistaken, but cPanel (and the other auto-admin tools) basically work the same way as previousely shown with the .htaccess file - i.e. basically look at the referrer string and make sure it's coming from the same domain (?)
     
    hulkster, Sep 7, 2005 IP
  10. kokopelli

    kokopelli Peon

    Messages:
    2,436
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #10
    My htaccess code looks like this
    My question, does it matter that I use the slash after the domain without brackets? I.e. "your_domain.com/" instead of "your_domain.com(/)"?

    And how about that second "?" after the domain?
     
    kokopelli, Sep 7, 2005 IP
  11. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #11
    You're right, but I allow requests with no refer, and so do the code pasted in this thread (the RewriteCond %{HTTP_REFERER} !^$ part.)
     
    blinxdk, Sep 8, 2005 IP