如何使这个 .htaccess 规则不区分大小写?

发布于 2024-08-26 14:05:25 字数 476 浏览 4 评论 0原文

这是我的 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

国际总奸 2024-09-02 14:05:25

来自 apache 文档的此页面 说你可以这样做像这样:

<FilesMatch \.(?i:csv)
gt;

This page from the apache docs says that you can do it like this:

<FilesMatch \.(?i:csv)
gt;
那小子欠揍 2024-09-02 14:05:25

不区分大小写:

<FilesMatch "(?i)\.(js|css|eot|ttf)$">

Case insensitive:

<FilesMatch "(?i)\.(js|css|eot|ttf)$">
深海夜未眠 2024-09-02 14:05:25

"\.[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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文