我想阻止对某些选定目录的直接 url 访问。但是然后使所选目录中的一些文件可以直接进行 url 访问。我在编写 <FilesMatch "\.(php)$">
在我的 httpd.conf 中,我设置了一个虚拟目录。在虚拟目录中,我添加了以下内容:
<DirectoryMatch "^/data/servers/dev.site.com/web/administrator/(includes|xml|css|javascript|stylesheet|cache|classes|acco
unt_files)">
AddType application/x-httpd-php .php .html .htm
Options none
AllowOverride All
Order Deny,Allow
Deny from all
#Target all files in "xml/" directory that end in ".php"
<FilesMatch "/xml/\.(php)">
AddType application/x-httpd-php .php
Order Allow,Deny
Allow from all
</FilesMatch>
</DirectoryMatch>
有人知道我应该怎么写吗?
感谢您的帮助。
最佳答案
FilesMatch 仅在文件名上工作 - 它根本不查看路径部分,因此您永远不会在 FilesMatch block 的文件名中获得“/xml/”。这就是上面有 DirectoryMatch 的原因。匹配那里的目录,然后匹配 dirmatch 中的文件名。
关于php - apache 文件匹配指令帮助。想要包含 "path/to/file"但无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4807573/