Apache RewriteCond

Associate
Joined
22 Jun 2009
Posts
808
Location
Norwich
Hi
my web server has a directory with PDFs I want to restrict access to
they should only be accessible through my application

so, if a user goes directly to the file like this:

/www/pdfs/sample.pdf

they should be denied access

BUT from within my application, the PDF can be viewed, and within that page the PDF is embedded in HTML like this:

<embed src="../../pdfs/sample.pdf?sid=1364756883#navpanes=0&view=FitH&scrollbar=1&toolbar=1" width="100%" height="800px">

The problem is that using RewriteCond like below:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?http://mysite[NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?http://mysite.*$ [NC]
RewriteRule \.(pdf)$ - [F]

This works ok if you directly try and access the PDF, but it ALSO blocks my embed code :(

Any suggestions? thanks :)
 
Back
Top Bottom