How to do location /test/place?id=2
P.V.Anthony
anthony at mindmedia.com.sg
Sun Oct 20 05:17:02 UTC 2019
On 19/10/19 4:22 pm, Aleksandar Lazic wrote:
> Have you tried Lewis suggestion with $arg_id, it looks exactly what you
> searching for?
>
> Untested:
> location = /test/place {
> if ($arg_id = "2") {
> return 301 https://new.example.com/test/place?$args;
> }
> }
I did try but it does not work when the uri has id=1 where id=1 should
remain and go to old.example.com.
The solution that works for me is as follows.
if ( $request_uri = "/test/place?id=2" ) {
rewrite ^ http://new.example.com${uri}?${args}? last;
}
Works with "return" also.
P.V.Anthony
More information about the nginx
mailing list