Apply URL encoding during rewrite rule
António P. P. Almeida
appa at perusio.net
Wed Feb 1 19:38:43 UTC 2012
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 ^/(.*)
> $scheme://$server_addr/?redirect_to=$scheme://$host$request_uri
> redirect;
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.
--- appa
More information about the nginx
mailing list