合并多个FilesMatch(特定文件)

时间:2018-07-02 09:08:47

标签: .htaccess

如何为特定文件组合多个FilesMatch?

我发现的所有示例都是用于组合文件扩展名的

就我而言,我只想允许3个文件:

/img/logo.png
/sound/true.p3
/sound/false.mp3

我测试过,但这并不干净:

<FilesMatch logo.png>
  Allow from all
  Satisfy Any
</FilesMatch>
<FilesMatch true.mp3>
  Allow from all
  Satisfy Any
</FilesMatch>
<FilesMatch false.mp3>
  Allow from all
  Satisfy Any
</FilesMatch>

1 个答案:

答案 0 :(得分:2)

您可以将<filesMatch>与正则表达式模式一起使用以测试多个文件

<filesMatch "(logo\.png|true\.p3|test\.jpg)">
Allow from all
Satisfy Any
</filesMatch>

FilesMatch指令的文档为here.