Welcome! Log In Create A New Profile

Advanced

Re: rewrite last using variable

Francis Daly
October 28, 2013 04:10AM
On Mon, Oct 28, 2013 at 01:56:16AM +0100, Ingo Schmidt wrote:

Hi there,

> set $var "/url?par=val";
> location = /b {
> rewrite ^ $var last;
> }

> For location b the redirect is internal and now the backend cannot
> process the request anymore.

> I guess that the URL encoding also takes place in the first case, but
> here the client decodes the URL and thus everything is ok again.

No; here what is sent to the client includes the bare ?.

> Is it possible in nginx to make rewrites with variables where the
> variable contains a URL with parameters like in the example? If yes,
> what do I need to change? If no, what other options do I have?

I believe it is intended to be "no", for internal rewrites at least.

You can do something like

set $var "/url";
set $vararg "par=val";
rewrite ^ $var?$vararg last;

Although you may need to be more subtle if you know that your backend
handles "/url" and "/url?" differently, in case $vararg is empty.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite last using variable

Ingo Schmidt October 27, 2013 08:58PM

Re: rewrite last using variable

Francis Daly October 28, 2013 04:10AM

Re: rewrite last using variable

Ingo Schmidt October 28, 2013 04:38AM

Re: rewrite last using variable

Francis Daly October 28, 2013 05:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 163
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready