Apache文件匹配:如何匹配除某些文件外扩展名

vjhs03f7  于 2023-01-05  发布在  Apache
关注(0)|答案(1)|浏览(107)

目前我们有:

# ----------------------------------------+++++----
<FilesMatch "(?i)(\.tpl|.twig|\.ini|\.log|\.txt)">
 Require all denied
</FilesMatch>

但是我们需要允许robots.txtads.txt
如何做到这一点?

sg24os4d

sg24os4d1#

试试这个:

(?i)(\.tpl|.twig|\.ini|\.log|(?<!robots|ads)\.txt)$

(?<!robots|ads)\.txt而不是robots,或者ads后面跟着.txt
$行/字符串的结尾。
参见regex demo

相关问题