2
votes

I am trying to rewrite é to e, using the htaccess file. All the following rules have all failed.

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

I have the following debug output, however am unable to figure out what it says.

197.178.121.8 - - [24/Feb/2014:00:29:35 --0800] [www.speaksheets.com/sid#7ff60b7a0318][rid#7ff60d1edf58/initial] (2) init rewrite engine with requested 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] (3) applying pattern '^(.*)' 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] (3) applying pattern '^(.*)' 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) pass through /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/] add path 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/ -> 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/] applying pattern '^index\.php$' 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] (3) [perdir /home/speaksheets.com/public_html/] add path 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/ -> 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/] applying pattern '.' 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] (2) [perdir /home/speaksheets.com/public_html/] rewrite 'translation/how-to-say-bon-app\xc3\xa9tit-in-french-bon-appetit/' -> '/index.php'

The question is, what is wrong with this rule, RewriteRule ^(.*)\xc3\xa9(.*) $1e$2 [R,L]?

2

2 Answers

0
votes

URLs cannot contain non-ASCII characters. All non-ASCII characters must be escaped to percent escapes like %C3%A9. ^(.*)é(.*) should never match a valid URL. \xYY is not defined as a byte escape sequence in Apache as far as I'm aware, so ^(.*)\xc3\xa9(.*) does not mean what you think it means either. The only valid rule is ^(.*)%C3%A9(.*), which contains the URL escaped version of a UTF-8 representation of "é".

0
votes

Your rule:

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

Is fine and should work (worked in my testing also).

But from rewrite log it appears some rule in internally rewriting it to index.php first.

Just make sure this above rule is very first rule in your .htaccess.