如何使用 FilesMatch 指令匹配文件名的一部分?例如,如果我想匹配“utilitiesForCurrentPage.js”或customWithOtherCharacters.css,我将如何实现这一点?我目前正在使用下面的指令。假设“utilitiesForCurrentPage.js”包含在文件夹中。
<Directory "/share/apache/files">
...
...
<FilesMatch "^(custom*|utilities*)\.(css|gif|jpg|jpeg|js)$">
Header set Cache-Control "public, max-age=1440, must-revalidate"
</FilesMatch>
</Directory>
最佳答案
表达式中缺少 .
(.
= 匹配除换行符之外的任何内容):
# need dot here -----v and ----v
<FilesMatch "^(custom.*|utilities.*)\.(css|gif|jpg|jpeg|js)$">
关于apache - 使用 FilesMatch 指令匹配文件名的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12220628/