I created a PHP website with login and users have access to PDF files. How can I prevent unauthorized users from accessing the PDF files via direct link?
I tried with .htaccess but "deny from all allow from localhost" also blocks my logged users. I tried with RewriteEngine and it allows all even if i delete the line with empty referer :
# ultimate hotlink protection
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?domain\. [NC]
RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L]
</ifModule>
What can I do?