restrict access with htaccess in web server

十年热恋 提交于 2020-04-30 11:46:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!