How to make this .htaccess rule case insensitive?

怎甘沉沦 提交于 2019-11-27 13:32:52

问题


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


回答1:


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

<FilesMatch \.(?i:csv)$>



回答2:


Case insensitive:

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



回答3:


"\.[cC][sS][vV]$"

It is still probably better to be consistent and rename the uploaded files as they arrive on your server.



来源:https://stackoverflow.com/questions/2520566/how-to-make-this-htaccess-rule-case-insensitive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!