hotlink protection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Grae
    Junior Member
    • Apr 2005
    • 6

    #1

    hotlink protection

    Hello,

    Trying to add some hotlink protection. I don't know much about apache yet, so I found a nice reference site that included some generated .htaccess code. It seems to be working, but I was wondering if there were any improvements I should make to the code. Are the flags correct?

    Code:
    RewriteEngine ON
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com(/)?.*$ [NC] 
    RewriteCond %{REQUEST_URI}  !^.*thief\.gif$ [NC]
    RewriteRule ^.*\.(gif|jpg|png|jpeg)$ http://www.mysite.com/images/thief.gif [NC,R,L]
    Little confused about the image that people see when trying to hotlink. Is it a problem that the image is within a hotlink protected directory?
  • sdjl
    Senior Member
    • Mar 2004
    • 502

    #2
    That should work perfectly well
    It does the following:

    If the referrer is blank or not your URL or the requested image is not theif.gif, then rewrite any requests for URL's containing .gif .jpg .png or .jpeg to the image theif.gif.

    Quite simple in its manner.

    You do realise there's something to generate this in cPanel automatically as well don't you?

    David
    -----
    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

    Comment

    • bhills
      Member
      • Mar 2004
      • 75

      #3
      I've heard varying reports on whether this actually works very well in the real world. Is it affective?

      Comment

      • Grae
        Junior Member
        • Apr 2005
        • 6

        #4
        Thanks for the replies
        You do realise there's something to generate this in cPanel automatically as well don't you?
        The code cPanel produced did not work for me. Not sure why. It had different syntax and used different flags.

        Comment

        Working...