This question have been on SO quite a few times, i have tried all the available options but still i am having hard time blocking a pdf file from direct access using absolute URL.
I using the following code inside .htaccess file which is in the same folder where pdf's are
Order Allow,Deny
<FilesMatch "^[^.]+\.(gif|jpe?g|png|pdf|doc|docx|txt|rtf|ppt|pptx|xls|mp4|mov|mp3|mpg|mpeg)$">
Deny from all
</FilesMatch>
When i access the directory of the pdf files it shows me a 403 forbidden access but the moment i enter the absolute url of the pdf it starts rendering the pdf in the browser.
Directory Url http://thetutlage.com/demo/pdfReader/files
Pdf Url :- http://thetutlage.com/demo/pdfReader/files/tracemonkey.pdf
Any help will be great. I have also tried using a redirect rule if a file has .pdf extension but that doesn't seems to be working as well.
Works fine:
Order Allow,Deny
Allow from all
<Files ~ "\.(gif|jpg|png|pdf)$">
Deny from all
</Files>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.