Apache 在htaccess中重写utf8字符

Apache 在htaccess中重写utf8字符,apache,.htaccess,mod-rewrite,utf-8,Apache,.htaccess,Mod Rewrite,Utf 8,我正在尝试使用htaccess文件将é重写为e。 以下所有规则均已失败 RewriteRule ^(.*)é(.*) $1e$2 [R,L] RewriteRule ^(.*)\xc3\xa9(.*) $1e$2 [R,L] RewriteRule ^(.*)%C3%A9(.*) $1e$2 [R,L] 我有下面的调试输出,但是我不知道它说了什么 197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60

我正在尝试使用htaccess文件将é重写为e。 以下所有规则均已失败

RewriteRule ^(.*)é(.*) $1e$2 [R,L]
RewriteRule ^(.*)\xc3\xa9(.*) $1e$2 [R,L]
RewriteRule ^(.*)%C3%A9(.*) $1e$2 [R,L]
我有下面的调试输出,但是我不知道它说了什么

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](2)初始化重写引擎,请求uri/翻译/如何用法语说苯教app\xc3\xa9tit/

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)将模式“^(.*)”应用于uri”/翻译/法语苯教app\xc3\xa9tit

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)将模式“^(.*)”应用于uri”/翻译/法语苯教app\xc3\xa9tit

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/首字母](1)传递/翻译/如何说法语苯教app\xc3\xa9tit/

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)[perdir/home/speaksheets.com/public_html/]添加路径信息后缀:/home/speaksheets.com/public_html/translation->/home/speaksheets.com/public_html/translation/home/speaksheets/public_html/translation/how-to-to-say-bon app\xc3\xa9;/

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)[perdir/home/speaksheets.com/public_html/]strip per dir prefix:/home/speaksheets.com/public_html/translation/how to say bon app\xc3\xa9tit in french bon appetit/->translation/how to say bon app\xc3\xa9tit in french bon appetit/

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)[perdir/home/speaksheets.com/public_html/]将模式“^index\.php$”应用于uri”翻译/如何用法语说苯教app xc3\xa9tit/'

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)[perdir/home/speaksheets.com/public_html/]添加路径信息后缀:/home/speaksheets.com/public_html/translation->/home/speaksheets.com/public_html/translation/home/speaksheets/public_html/translation/how-to-to-say-bon app\xc3\xa9;/

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)[perdir/home/speaksheets.com/public_html/]strip per dir prefix:/home/speaksheets.com/public_html/translation/how to say bon app\xc3\xa9tit in french bon appetit/->translation/how to say bon app\xc3\xa9tit in french bon appetit/

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](3)[perdir/home/speaksheets.com/public_html/]应用模式“.”到uri翻译/如何用法语说苯教app\xc3\xa9tit/“苯教”

197.178.121.8---[24/Feb/2014:00:29:35--0800][www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](2)[perdir/home/speaksheets.com/public_html/]重写“翻译/如何说法语苯教app\xc3\xa9tit/”->“/index.php”


问题是,这个规则有什么问题,
重写规则^xc3\xa9(.*)$1e$2[R,L]

URL不能包含非ASCII字符。所有非ASCII字符必须转义为百分比转义,如
%C3%A9
<代码>^(.*)é(.*)不应与有效的URL匹配<据我所知,代码>\xYY在Apache中没有定义为字节转义序列,因此
^(.*)\xc3\xa9(.*)
也不是您认为的意思。唯一有效的规则是
^(.*)%C3%A9(.*)
,它包含“é”的UTF-8表示的URL转义版本。

您的规则:

RewriteRule ^(.*)\xc3\xa9(.*) $1e$2 [R,L]
很好,应该可以工作(在我的测试中也工作过)

但从重写日志来看,首先在内部将其重写到
index.php
中似乎有一些规则


只需确保上述规则是.htaccess中的第一条规则。

“é”在调试日志中表示为\xc3\xa,它对规则的匹配是否有任何影响?我不确定
\xYY
是否有任何特殊意义,但就我所知,它肯定不代表Apache或URL中的字节转义序列,因此它肯定不会产生你可能认为它具有的效果。你是对的,我已经把它作为第一条规则写了下来,现在它工作得很好。请您提供完整的
.htaccess
,删除
index.php
表单url?评论部分用于讨论问题或发布答案,而不是询问新代码。你应该发布一个包含所有细节的新问题。