我的.htaccess:
RewriteEngine叙述上
CheckCaseOnly在
CheckSpelling在
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-l
重写规则^博客/(.*?)$ /Me/profile.php?username=$1 [QSA,L]
现在的问题是,当URL是这样的,它的工作原理:
本地主机/ ME /博客/ ExampleUser
但是,当它是这样它不工作(请注意'博客'的'B'是小写):
本地主机/ ME /博客/ ExampleUser
我的XAMPP的新版本上运行它。这是奇怪的,虽然我对PHP配置的mod_speling.so它不工作,甚至。
这是什么问题?
解决方案使用[NC]标志导致要匹配不区分大小写的方式重写规则。也就是说,它并不关心的字母是否显示为大写或小写在匹配URI
尝试 [QSA,L,NC]
代替,所以比较时的在不区分大小写的方式
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?
解决方案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