gpt4 book ai didi

php - apache 文件匹配指令帮助。想要包含 "path/to/file"但无法正常工作

转载 作者:可可西里 更新时间:2023-11-01 12:50:13 25 4
gpt4 key购买 nike

我想阻止对某些选定目录的直接 url 访问。但是然后使所选目录中的一些文件可以直接进行 url 访问。我在编写 部分以允许访问“xml/”目录中的 .php 文件时遇到了一些问题。我想在 filesmatch 指令中包含部分“路径”,而不是为我想要某些文件可用的每个目录创建单独的 < directorymatch > 指令,但它不起作用......如果我删除“/xml/"并放入 <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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com