Rewriting uri as querystring using nginx?

How do I rewrite URIs of the form

http://domain1/one/two?three=four

to

http://domain2?path=http%3A%2F%2Fdomain1%2Fone%2Ftwo%3Fthree%3Dfour

using nginx?

Posted at Nginx Forum:

On 2012-02-23 12:45, junius wang wrote:

How do I rewrite URIs of the form

http://domain1/one/two?three=four

to

http://domain2?path=http%3A%2F%2Fdomain1%2Fone%2Ftwo%3Fthree%3Dfour

Perhaps something like this:

rewrite ^ http://domain2?path=http://domain1$request_uri$is_args$args
permanent;

Not sure about the escapes though.

On 23 Fev 2012 06h45 CET, [email protected] wrote:

How do I rewrite URIs of the form

http://domain1/one/two?three=four

to

http://domain2?path=http%3A%2F%2Fdomain1%2Fone%2Ftwo%3Fthree%3Dfour

To escape you need to do a capture.

rewrite ^(.*)$ http://domain2?path=$1;

— appa