ChampagneGal
asked on
htaccess file to restrict download of pdf files unless they are a registered user
I'm new to this. I want to make sure that my pdf files cannot be downloaded if someone just types that path to the pdf file in the browser. I plan on restricting the link to the pdf files on my webpages in my php code.
It sounds like I need to use an .htaccess file but I'm not sure how to write it. Can anyone help me???
Thanks in advance...
It sounds like I need to use an .htaccess file but I'm not sure how to write it. Can anyone help me???
Thanks in advance...
If you just want to show a 403 page, to any request on pdf file, then you can use this instead
<FilesMatch "\.(pdf)$">
order deny,allow
deny from all
</FilesMatch>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much. I did not know that was possible so I'm looking forward to trying this.
ASKER
If I put my video files outside of the root will that keep people from being able to download them via Real Player?
yeah, same principal - just proxy it through with php's file_get_contents()
If you run into trouble with the browser recognizing the file type, you may have to apply a mime type with the header function. You can also force the file to download as it's original name (and any number of other things) with the header function:
header('Content-type: application/pdf');
header('Content-Dispositio n: attachment; filename="downloaded.pdf"' );
If you like, also look at "readfile()" as a file_get_contents() alternative.
If you run into trouble with the browser recognizing the file type, you may have to apply a mime type with the header function. You can also force the file to download as it's original name (and any number of other things) with the header function:
header('Content-type: application/pdf');
header('Content-Dispositio
If you like, also look at "readfile()" as a file_get_contents() alternative.
ASKER
Thanks, I'll try it tomorrow. Happy Thanksgiving :-)
Open in new window