Content - RewriteCond case sensitive for %{REQUEST_FILENAME}

#1
I am running 2.1.9 std on Debian Linux. I have a static context set up for my WordPress installation with a RewriteBase of /blog/ and the following as my rewrite rules:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php

This works fine, except that the -f and -d tests appear to be case sensitive, which is not the behavior I expected. I was under the impression that URI requests are case-insensitive, so, for instance, www.mydomain.com/blog/Test/index.html and www.mydomain.com/blog/test/index.html should resolve to the same thing. This does not work, however. If I have a directory named Test (mixed case) and try the URL with test (lower case) in it, the RewriteRule gets called. If I try the URL with the mixed case name, it correctly displays the file.

As stated in the Apache Rewrite docs, adding the [NC] option doesn't change this behavior, as [NC] doesn't apply to filesystem tests.

Is this a bug, or is it a misconception on my part? Is there some way to effectively make these case insensitive for those clueless web surfers who like to type in Index.html?

Thanks so much for you reply,
Jason
 

mistwang

LiteSpeed Staff
#2
Thank you for trying our product.

It is not a bug in LSWS, that's exactly how the rewrite rule should work on a case sensitive file system. Same thing will happen to Apache as well.

It is a good idea to stick to lower case for all of your directories.

Is there some way to effectively make these case insensitive for those clueless web surfers who like to type in Index.html?
No, it is not possible within write rules. My suggestion is to use all lower case for directories and files, then you can use internal rewrite map function to covert the string to lowercase then do the file system test if you want.
 
#3
that's exactly how the rewrite rule should work on a case sensitive file system [Apache]

No, it is not possible within write rules.
That's not true for apache :)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php

As stated in the Apache Rewrite docs, adding the [NC] option doesn't change this behavior, as [NC] doesn't apply to filesystem tests.

.. a misconception on my part?

With an additional condition and some creativity you can achieve insensitivity:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ [NC]

adapt to suit
 
Top