How to do location /test/place?id=2

P.V.Anthony anthony at mindmedia.com.sg
Thu Oct 17 17:01:25 UTC 2019


Hi,

Currently have the following url,

https://old.example.com/test/place?id=1
https://old.example.com/test/place?id=2
https://old.example.com/test/place?id=3

Need to redirect only id=2 to another url.

Did the following and it works for id=2. Need id=1 and id=3 to continue 
normally without change.

location = /test/place {
      if ($args = "id=2") {
        return 301 https://new.example.com/test/place?$args;
     }
}


Or is there a way to do the following? That would be ideal.


location = /test/place?id=2 {
     return 301 https://new.example.com/test/place?id=2
}

Unfortunately the above does not work. What is missing?

-- 
P.V.Anthony



More information about the nginx mailing list