我已经inheritance了一个devise不佳的Web应用程序,它具有需要公开访问的特定文件,但该文件位于不应该存在的目录中。
换句话说,我需要一种方法来阻止目录中的所有文件和子目录,但是将其覆盖到一个文件中。
我正在尝试这个:
# No one needs to access this directly <Directory /var/www/DangerousDirectory/> Order Deny,allow Deny from all # But this file is OK: <Files /var/www/DangerousDirectory/SafeFile.html> Allow from all </Files> </Directory>
但是它不能正常工作 – 它只是阻止包括我想要允许的文件在内的所有内容。 有什么build议么?
在StackOverflow上有一个答案应该回答这个问题,我认为在嵌套的Files
指令中有一个缺less的Order
?
# No one needs to access this directly <Directory /var/www/DangerousDirectory/> Order Deny,allow Deny from all </Directory> # But this file is OK: <Files /var/www/DangerousDirectory/SafeFile.html> Order Deny,Allow Allow from all </Files>
如果这个目录是密码保护的,也可以添加Satisfy any
。
答案很晚,但也许还是答案。
该标签在目录的范围内,不应该有完整的path。 所以它应该是:
<Directory "/var/www/DangerousDirectory"> Order Deny,allow Deny from all # But this file is OK: <Files "SafeFile.html"> Allow from all </Files> </Directory>
请注意,这将允许在该目录树中称为SafeFile.html的任何文件。