.htaccess 区分大小写和 mod_rewrite [英] .htaccess case sensitive and mod_rewrite

查看:21
本文介绍了.htaccess 区分大小写和 mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.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]

问题是,当 URL 是这样的时候,它是有效的:

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

localhost/Me/Blog/ExampleUser

但是这样就不行了(注意'Blog'中的'b'是小写的吗?):

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

localhost/Me/blog/ExampleUser

我在新版本的 XAMPP 上运行它.即使我在 PHP 配置中有 mod_speling.so,它也无法正常工作.

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.

有什么问题?

推荐答案

使用 [NC] 标志会导致 RewriteRule 以不区分大小写的方式进行匹配.也就是说,它不关心字母在匹配的 URI 中是大写还是小写.

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.

试试[QSA,L,NC],这样比较就以不区分大小写的方式

这篇关于.htaccess 区分大小写和 mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆