如何使这个 .htaccess 规则不区分大小写?
这是我的 .htaccess 中的一条规则,
# those CSV files are under the DOCROOT ... so let's hide 'em
<FilesMatch "\.CSV$">
Order Allow,Deny
Deny from all
</FilesMatch>
但我注意到,如果有一个文件具有小写或混合大小写的 CSV 扩展名,该规则将忽略该文件并显示。
如何使这种情况不区分大小写?
我希望它不会归结为 "\.(?:CSV|csv)$"
(我不确定它是否有效,并且没有涵盖所有基础)
注意:这些文件位于文档根目录下,并由第 3 方服务自动上传到那里,因此我更愿意自己实现一个规则,而不是打扰他们。如果我设置了这个网站,我会选择高于文档根目录的位置。
谢谢
This is a rule in my .htaccess
# those CSV files are under the DOCROOT ... so let's hide 'em
<FilesMatch "\.CSV$">
Order Allow,Deny
Deny from all
</FilesMatch>
I've noticed however that if there is a file with a lowercase or mixed case extension of CSV, it will be ignored by the rule and displayed.
How do I make this case insensitive?
I hope it doesn't come down to "\.(?:CSV|csv)$"
(which I'm not sure would even work, and doesn't cover all bases)
Note: The files are under the docroot, and are uploaded automatically there by a 3rd party service, so I'd prefer to implement a rule my end instead of bothering them. Had I set this site up though, I'd go for above the docroot.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 apache 文档的此页面 说你可以这样做像这样:
This page from the apache docs says that you can do it like this:
不区分大小写:
Case insensitive:
"\.[cC][sS][vV]$"
最好保持一致,并在上传的文件到达您的服务器时重命名它们。
"\.[cC][sS][vV]$"
It is still probably better to be consistent and rename the uploaded files as they arrive on your server.