用于单个文件 HTACCESS 的 FilesMatch 或文件

FilesMatch or Files for Single File HTACCESS

我的网站有包含 index.html 个文件的子目录。

www.domain.com/.htaccess 
www.domain.com/index.html
www.domain.com/otherstuff/index.html

我在 .htaccess 文件中有以下内容到 运行 我的主索引页面上的一些 php 代码,但我知道它也会影响我子目录中的 index.html 文件。我该如何写才能使其仅适用于 www.domain.com/index.html?

<Files index.html>
AddHandler x-httpd-php5-cgi .html
</Files>

我发现了这个: Precise targeting of the Filesmatch directive

但我对使用重定向等替代方法不感兴趣,因为它无法回答问题。我想知道是否可以 this 方式,如果可以,怎么做?如果实际上不可能,那么我会知道这一点以供将来参考,并将始终使用替代方案。

谢谢!

查看 RemoveHandler 文档:

The RemoveHandler directive removes any handler associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files.

所以在 "otherstuff" 目录中,添加另一个 htaccess 文件,上面写着:

<Files index.html>
RemoveHandler  .html
</Files>