简体   繁体   中英

htaccess error pages and authentication

Task 1: I am using htaccess Options -Indexes to stop directory listing. However, I want it to show 404 page not found response instead of 403 forbidden response. How can I do that for each directory?

Task 2: Suppose I have a directory that contains some downloadable files. Is there a way I can stop the users from downloading the files using .htaccess until they are logged into my site?

Task 1: Try this

RewriteEngine On
RewriteBase   /my_directory
RewriteRule   ^$ - [R=404,L]

Task 2: First you need to prevent direct file downloading using htaccess.
Then you have to create your php file to check whether logged in or not.
If logged then, set header as your target file, and open it.

These 2 tutorials will guide you.
http://www.ssdtutorials.com/tutorials/title/download-file-with-php.html
http://www.devshed.com/c/a/PHP/Simple-and-Secure-PHP-Download-Script-with-Limits-Tutorial/

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM