问题
I am using wordpress and I have a folder under wp-content/ structured as:
folder
|-folder1
|-file.pdf
|-folder2
|-.htaccess
I have all PDF files distributed within subfolders in the folder directory. I don't want all files inside the folder to be accessed directly. so I place the code in .htaccess
deny from all
but this does not seem to prevent that purpose. when I enter this url: http://mysite.come/wp-content/folder/folder1/file.pdf, the file still can be downloaded, which it shouldn't. what seems to be wrong here? thanks for help.
回答1:
the .htaccess file sets directives to the current folder and sub-folders.
important:
- make sure that you have enabled AllowOverride All for that directory in the webserver configuration (if it is set to None change it to All and restart the web server).
- if you want to override a directive set in an parent folder you have to place a .htaccess file in every folder you want to override (including the directives you want to override).
来源:https://stackoverflow.com/questions/8642967/restrict-access-with-htaccess-in-web-server