如何从FilesMatch中排除目录 [英] How to exclude a directory from FilesMatch
问题描述
我有以下.htaccess指令:
I have the following .htaccess directive:
<FilesMatch ".(htm|html|php)$">
php_value auto_prepend_file "/home/abc/public_html/_prepend.php"
php_value auto_append_file "/home/abc/public_html/_append.php"
</FilesMatch>
我需要从目录中排除非常具体的目录'/ home / abc / public_html / exclude /`。
I need to exclude a very specific directory '/home/abc/public_html/exclude/` from the auto_prepend and auto_append.
有可能吗?
推荐答案
。htaccess文件-它们是什么/如何使用解释了 .htaccess
文件正常工作
放置了一个包含一个或多个配置指令的文件
A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.
这意味着,您可以创建一个。 htaccess文件位于 / home / abc / public_html /
中,另一个文件位于 / home / abc / public_html / exclude /
This means, you can create a .htaccess file in /home/abc/public_html/
, and another one in /home/abc/public_html/exclude/
containing the same, different, or even contradicting directives.
查看 PHP- auto_prepend_file
,您可以看到
Looking at PHP - auto_prepend_file
, you can see that
特殊值
none
禁用自动添加。
相同适用于 auto_append_file
。
将这两件事放在一起意味着您可以拥有现有的.htaccess
Putting these two things together means, you can have the existing .htaccess
# /home/abc/public_html/.htaccess
<FilesMatch ".(htm|html|php)$">
php_value auto_prepend_file "/home/abc/public_html/_prepend.php"
php_value auto_append_file "/home/abc/public_html/_append.php"
</FilesMatch>
和排除
中的第二个.htaccess子目录
and a second .htaccess in the exclude
subdirectory
# /home/abc/public_html/exclude/.htaccess
<FilesMatch ".(htm|html|php)$">
php_value auto_prepend_file none
php_value auto_append_file none
</FilesMatch>
这篇关于如何从FilesMatch中排除目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!