Home > Software design >  apache filematch: how to match extension except some files
apache filematch: how to match extension except some files

Time:01-06

Currently we have:

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

But we need to allow robots.txt and ads.txt.

How to achieve that?

CodePudding user response:

Try this:

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

(?<!robots|ads)\.txt not robots or ads followed by .txt.

$ the end of the line/string.

See regex demo

  • Related