2014-02-24 35 views
1

我正在尝试使用htaccess文件重写e到e。 以下所有规则全部失败。在htaccess中重写utf8字符

RewriteRule ^(.*)é(.*) $1e$2 [R,L] 
RewriteRule ^(.*)\xc3\xa9(.*) $1e$2 [R,L] 
RewriteRule ^(.*)%C3%A9(.*) $1e$2 [R,L] 

我有下面的调试输出,但我无法弄清楚它说什么。

197.178.121.8 - - [24 /二月/ 2014:00:29:35 --0800] [www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial](2)初始化重写引擎与请求的uri/translation/how-to-say-bon-app \ xc3 \ xa9tit-in-french-bon-appetit/

197.178.121.8 - - [24/Feb/2014:00:29:35 (3)将模式'^(。*)'应用于uri'/ 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] [ (#7ff60d1edf58/initial)(3)应用模式'^(。 *)'to uri'/ 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](1)通过/翻译/ 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/]添加路径信息后缀:/home/speaksheets.com/public_html/translation - > /home/speaksheets.com/public_html/translation/how-to-say-bon-app \ xc3 \ xa9tit-in-french-bon-appetit/

197.178.121.8 - - [24/Feb/2 014: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/ - >翻译/ 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/初始](3)[perdir /home/speaksheets.com/public_html/]将模式'^ index \ .php $'应用于uri'翻译/ 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/] add p ath info postfix:/home/speaksheets.com/public_html/translation - > /home/speaksheets.com/public_html/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/] strip per-dir prefix:/home/speaksheets.com/public_html/translation/how-to-say-bon-app\xc3\xa9tit-in-french-bon-appetit/ - >翻译/ how-to-say-bon-app \ xc3 \ xa9tit-in-french-bon-appetit/

197.178.121.8 - - [24/Feb/2014:00:29:35 - 0800] [www。 [3] [perdir /home/speaksheets.com/public_html/]应用模式'。' to'uri'翻译/ 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](2)[perdir /home/speaksheets.com/public_html/] rewrite'translation/how-to-say-bon-app \ xc3 \ xa9tit-in-french-bon-appetit /' - >'/ index。php'

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

回答

0

您的规则:

RewriteRule ^(.*)\xc3\xa9(.*) $1e$2 [R,L] 

是好的,应该工作(在我的测试工作也)。

但是,从重写日志出现一些规则,首先在内部重写它到index.php

只要确保这个规则是非常规则在您的.htaccess。

+0

你是对的,我写它作为第一条规则,现在它的工作完美 – hyena

+0

你能否提供完整的'''.htaccess'''去除''''index.php'''形式的url? – kishor10d

+0

评论部分用于讨论问题或发布答案,而不是询问新代码。你应该发布一个包含所有细节的新问题。 – anubhava

0

URL不能包含非ASCII字符。所有非ASCII字符必须转义为百分号转义,如%C3%A9^(.*)é(.*)应该永远不会匹配有效的网址。就我所知,\xYY没有在Apache中定义为字节转义序列,所以^(.*)\xc3\xa9(.*)并不意味着你认为它的意思。唯一有效的规则是^(.*)%C3%A9(.*),其中包含“é”的UTF-8表示的URL转义版本。

+0

“é”在调试日志中表示为\ xc3 \ xa,它是否对规则的匹配有任何影响? – hyena

+0

我不确定'\ xYY'是否有任何特别的意义,但是它确实不代表Apache或URL中的字节转义序列,只要我知道,所以它肯定不会影响你可能会认为它有。 – deceze