<FilesMatch "\.html$">
如何在基本目录中仅指定 .html文件?
我想要
https://www.example.com/page.html
但不是 https://www.example.com/directory/page.html
答案 0 :(得分:2)
由于该规则位于根目录的.htaccess
中,如下面的讨论所述,因此请尝试
<FilesMatch "^\.(html|php)$">
<If "%{REQUEST_URI} =~ m#^/[^/]+\.(html|php)$#">
(your directives)
</If>
</FilesMatch>
请参见https://httpd.apache.org/docs/2.4/sections.html#file-and-web,https://httpd.apache.org/docs/2.4/mod/core.html#if和https://httpd.apache.org/docs/2.4/expr.html。