htaccess hotlinking redirect from direct images

Discussion in 'Apache' started by convex7, Mar 9, 2008.

  1. #1
    Hello all,

    I have searched the entire forum and google, but I can't seem to get this to work.

    I am trying to redirect users who click on a link to a direct image such as images/file.jpg

    What I want to do is redirect them to mysite.com/viewer.php?file=filename.jpg instead as to prevent hot linking.

    Where do I need to add the htaccess file and what do I need to put in it?

    Any help is greatly appreciated!
     
    convex7, Mar 9, 2008 IP
  2. danielc

    danielc Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    http://www.google.com.hk/search?q=apache%2Chotlink&complete=1&hl=zh-TW
     
    danielc, Mar 9, 2008 IP
  3. convex7

    convex7 Peon

    Messages:
    157
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for trying to help but I couldn't really find what I was looking for.

    I managed to get this working:

    RewriteEngine On
    RewriteRule ^([A-Za-z/0-9-]+)\.png$ http://www.faveimage.com/script.php?img=$1&type=png&ref=%{HTTP_REFERER} [L,NS]
    RewriteRule ^([A-Za-z/0-9-]+)\.jpg$ http://www.faveimage.com/script.php?img=$1&type=jpg&ref=%{HTTP_REFERER} [L,NS]
    RewriteRule ^([A-Za-z/0-9-]+)\.gif$ http://www.faveimage.com/script.php?img=$1&type=gif&ref=%{HTTP_REFERER} [L,NS]
    Code (markup):
    But now the thumbnail doesn't show. I added the appropriate code to the script.php file.
     
    convex7, Mar 10, 2008 IP