How block access to url directory

2019-09-07 05:24发布

I have the follow link : www.mysite.com/uploads/file.pdf

I want the user to download the file. But I do not want him vizualize files from this directory. How can I do this?

I'm using PHP and Apache.

2条回答
ら.Afraid
2楼-- · 2019-09-07 06:02

Even better use Options -Indexes in your .htaccess file

create a file named .htaccess on that directory and add Options -Indexes as the content of the file. Make sure you hit enter after adding Options -Indexes

This will make sure that your directory will not be index able . i.e you can access the file say www.mysite.com/uploads/file.pdf but you cannot list all the files in that directory using www.mysite.com/uploads/

查看更多
Viruses.
3楼-- · 2019-09-07 06:10

Adding an empty file called index.html into the directory www.mysite.com/uploads/ will prevent the user from being able to see(visualize) the files.

Disabling directory indexes will also work How do I disable directory browsing?

查看更多
登录 后发表回答