Apply URL encoding during rewrite rule
lists at wildgooses.com
Wed Feb 1 20:59:41 UTC 2012
On 01/02/2012 19:38, António P. P. Almeida wrote:
> On 1 Fev 2012 19h24 WET, lists at wildgooses.com wrote:
>> Hi, I need to do a redirect and pass the old URL to the redirected
>> destination. How might I achieve this using nginx?
>> I tried a rewrite rule simply: rewrite ^/(.*)
> To escape do a rewrite with a capture. Above you're capturing but not
> using the numeric group $1. Try:
> rewrite ^/(.*)$ $scheme://$server_addr/?redirect_to=$scheme://$host/$1 redirect.
OK, that nearly works, but it adds an extra & when nginx appends the
This is closer:
However, for some reason the $1 is still *decoded* ? From reading
various past threads on this, I thought that a regexp would grab the
still encoded $uri part?
So I don't see any difference between using $1 or $uri to capture the
uri, and in both cases it will decode a uri such as:
Am I missing something that is causing this to happen? How to grab the
$uri without decoding?
Nearly there! Thanks
More information about the nginx