带有转义参数的htaccess中的mod_rewrite

时间:2014-12-04 10:59:56

标签: regex .htaccess mod-rewrite redirect escaping

我想要从www.xyz.com/test/123http://www.zxy.de/?learningCardsDeeplinkUrl=http%3A%2F%2Ftest1.test2.com%2Findex.html%23%21%2FflashCard%2F123123

的htaccess重定向

并在htaccess中尝试此条目:

RewriteRule ^test/(.*)$ http://www.zxy.de/?learningCardsDeeplinkUrl=http%3A%2F%2Ftest1.test2.com%2Findex.html%23%21%2FflashCard%2F$1

结果是: targetUrl=httpAFFtest1.test2.comFindex.html31FflashCardF123

目标网址中缺少%。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您需要在目标网址中转义%,因为%3%2等表示来自RewriteCond反向引用变量:

RewriteRule ^test/(.*)$ http://www.zxy.de/?learningCardsDeeplinkUrl=http\%3A\%2F\%2Ftest1.test2.com\%2Findex.html\%23\%21\%2FflashCard\%2F$1 [L,R,NE]