Thorsten Rintelen
Thorsten Rintelen

Reputation: 568

mod_rewrite in htaccess with escaped parameter

I want a htaccess redirection from www.xyz.com/test/123 to http://www.zxy.de/?learningCardsDeeplinkUrl=http%3A%2F%2Ftest1.test2.com%2Findex.html%23%21%2FflashCard%2F123123

and try this entry in htaccess:

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

The result is: targetUrl=httpAFFtest1.test2.comFindex.html31FflashCardF123

The % is missing in the target url.

Any idea?

Upvotes: 1

Views: 48

Answers (1)

anubhava
anubhava

Reputation: 785058

You need to escape % in target URL since %3, %2 etc denote back-reference variables from RewriteCond:

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

Upvotes: 1

Related Questions