Reputation: 11
I created a php script that allows you to download and upload files. Files are saved to a directory XXX. Can I add an htaccess file to protect files in this folder? I would want that people must login to my web site to download files. I would want that people who know the position of XXX can not download file without to login to control panel of my web site. What should I write in this htaccess file? The site is hosted. Files can have any extension.
Upvotes: 0
Views: 133
Reputation: 210
You can do something like this in your htaccess:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^files/([^/]+)/([^/]+).zip /download.php?folder=$1&file=$2 [NC]
All requests to files/XXX/YYY.zip
will be rewritten to files/download.php?folder=XXX&file=YYY
and your php can handle the authentication.
Upvotes: 1