views:

193

answers:

2

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

A: 

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

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

Coronatus
That will work for `csv` and `CSV` cases only. Ideally, I'd prefer for it match all instances of mixed case.
alex
Thanks for your answer mate, but that's a bit hacky.
alex
@alex That matches cSv too.
toscho
@toscho I know, and I would of gone with this answer had there not been a better way.
alex
+3  A: 

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

<FilesMatch \.(?i:csv)$>
Chad Birch
Exactly what I was chasing... many thanks.
alex