Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess case sensitive and mod_rewrite

Tags:

.htaccess

My .htaccess:

RewriteEngine On
CheckCaseOnly On
CheckSpelling On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^Blog/(.*?)$ /Me/profile.php?username=$1 [QSA,L]

The problem is, when the URL is like this, it works:

localhost/Me/Blog/ExampleUser

But it doesn't work when it is like this (notice the 'b' in 'Blog' is in lowercase?):

localhost/Me/blog/ExampleUser

I'm running it on the new version of XAMPP. It is wierd its not working even though I have the mod_speling.so on the PHP config.

What is the problem?

like image 691
Cole Avatar asked May 16 '13 05:05

Cole


2 Answers

Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn't care whether letters appear as upper-case or lower-case in the matched URI.

Try [QSA,L,NC] instead, so the comparison is made in a case-insensitive manner

like image 82
Felipe Alameda A Avatar answered Sep 18 '22 13:09

Felipe Alameda A


the problem is that rewrite rules ARE case sensitive. So your Rewrite rule should be:

RewriteRule ^[Bb]log/(.*?)$ /Me/profile.php?username=$1 [QSA,L]

and voila you are fixed.

mod_speling.so has NOTHING to do with this.

like image 24
Ahmed Masud Avatar answered Sep 17 '22 13:09

Ahmed Masud