Welcome! Log In Create A New Profile

Advanced

Re: Rewriting query string

Francis Daly
December 30, 2019 07:04AM
On Sun, Dec 29, 2019 at 04:41:58AM -0500, Olaf van der Spek wrote:

Hi there,

> > rewrite ^(.*)$ $1?ra=$remote_addr break;
>
> The ra argument is inserted before the original query string. Is it possible
> to append it to the original query string?

Something like

rewrite ^(.*)$ $1?$args&ra=$remote_addr? break;

should work. Note that it might look odd if there was no original
query string.

Also note - common practice on the web seems to be that the order of
key=value pairs in the query string is unpredictable; you may be happier
if you change your back-end to not care about the order (if you want
random web browsers to work with your application).

> Is this behavior documented somewhere? Couldn't find it.

http://nginx.org/r/rewrite

"""
If a replacement string includes the new request arguments, the previous
request arguments are appended after them.
"""

> Can one also remove certain arguments from the query string this way?

Not easily, this way.

For that, you probably want either to use one of the embedded languages
to manipulate things; or to use the module referenced in the other reply.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewriting query string

Olaf van der Spek December 29, 2019 04:41AM

Re: Rewriting query string

Sergey A. Osokin December 29, 2019 07:00AM

Re: Rewriting query string

Francis Daly December 30, 2019 07:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 203
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