apache - 如何从 FilesMatch 中排除目录

标签 apache .htaccess

我有以下 .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>

我需要从 auto_prepend 和 auto_append 中排除一个非常具体的目录 '/home/abc/public_html/exclude/`。

可能吗?

最佳答案

.htaccess files - What they are/How to use them解释 .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.

这意味着,您可以在 /home/abc/public_html/ 中创建一个 .htaccess 文件,并在 /home/abc/public_html/exclude/ 中创建另一个包含以下内容的 .htaccess 文件:相同、不同、甚至矛盾的指令。

<小时/>

查看 PHP - auto_prepend_file ,你可以看到

The special value none disables auto-prepending.

这同样适用于auto_append_file

<小时/>

将这两件事放在一起意味着,您可以拥有现有的 .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>

以及 exclude 子目录中的第二个 .htaccess

# /home/abc/public_html/exclude/.htaccess
<FilesMatch ".(htm|html|php)$">
  php_value auto_prepend_file none
  php_value auto_append_file none
</FilesMatch>

关于apache - 如何从 FilesMatch 中排除目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43640403/

相关文章:

python - 为子域设置 SERVER_NAME 后 flask 中 www 前缀的问题

apache - Hbase ipc.RpcServer responseTooSlow 问题和区域服务器关闭

PHP 执行 ('git' )失败

apache - .htaccess SSL 和非 SSL,带 www 到非 www 重定向

php - 如何从 Symfony2 URL 中删除 "web/app_dev.php"?

php - 如何在 Apache 中访问一个文件夹?

php - 在 PHP 中执行服务器端输出缓存的最佳方法是什么?

xml - InelliJ和apache tomcat8在.IntelliJIdea15/system/tomcat/Unnamed_Form/conf目录下发现没有server.xml

.htaccess - 使用 htaccess 将所有域别名重定向到一个

.htaccess - 将子域重定向到顶级域的文件夹