4 Replies Latest reply on Apr 8, 2010 3:25 PM by 370H55V

    htaccess conflict (preventing hotlinking)

    andreas1969 Level 1

      I have a website that uses a perl script to password protect certain directories containing files in multiple formats (html, csv, pdf, jpg, etc)  I'm using .htaccess file to prevent hotlinking.  However, when I add the pdf extension to the htaccess file, the pdf files do not display correctly for users that correctly log in.

       

      In IE8, multi-page pdf files are opened, but only the first page is displayed and all others are blank.  Also, the browser window sometimes freezes.  FF doesnt display any part of the pdf.  If the pdf extension is not included in the htaccess file, pdf files display properly in all browsers.

       

      Here is the coding for the htaccess file without the pdf extension (works correctly):

       

      RewriteEngine On
      # RewriteCond %{HTTP_REFERER} !^http://(.+\.)?commoditywx\.com/ [NC]
      RewriteCond %{HTTP_REFERER} !^http://(www\.)?commoditywx\.com/ [NC]
      RewriteRule .*\.(jpe?g|gif|bmp|png|html|csv)$ - [F]

       

      Here is the coding for the htaccess file with the pdf extension (does not display pdf files properly)

       

      RewriteEngine On
      # RewriteCond %{HTTP_REFERER} !^http://(.+\.)?commoditywx\.com/ [NC]
      RewriteCond %{HTTP_REFERER} !^http://(www\.)?commoditywx\.com/ [NC]
      RewriteRule .*\.(jpe?g|gif|bmp|png|html|pdf|csv)$ - [F]

       

      Any ideas why this is not working?  If I can't use htaccess to prevent hotlinking to pdf files, is there another way?

       

      -George