Here's a rewrite rule to only allow thumbnails to be hotlinked

Discussion in 'Apache' started by darkmessiah, Jan 9, 2008.

  1. #1
    So far so good. I did a test where I hotlinked 2 images.. one with filename_thumb.jpg the other filename.jpg. The filename_thumb.jpg image displayed.

    The rewrite stuff is such pain, enjoy.

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
    RewriteCond %{REQUEST_FILENAME} !.*_thumb.(gif|GIF|jpg|JPG|jpeg|JPEG)$ [NC]
    RewriteRule .*\.(gif|GIF|jpg|JPG|jpeg|JPEG)$ - [F]
     
    darkmessiah, Jan 9, 2008 IP
  2. Dr. XYZ

    Dr. XYZ Guest

    Messages:
    226
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sounds great, thanks for sharing!

    ·​
     
    Dr. XYZ, Jan 9, 2008 IP