I know this is not an answer to your question, but it begs another, mainly
due to the if statement. How many of these are you going to have?
https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
You've likely considered this, but if not wanted to throw it out there.
Even if you are moving domains, could you create a separate route that you
could key off rather than arg_id?
Random thoughts waiting for things to compile
On Thu, Oct 17, 2019 at 5:15 PM J. Lewis Muir <jlmuir@imca-cat.org> wrote:
> On 10/18, P.V.Anthony wrote:
> > 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;
> > }
> > }
>
> You might want to use $arg_id here (i.e., the $arg_<name> variable for
> the <name> argument). Otherwise, it won't work if any other arguments
> are given.
>
> > 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
> > }
>
> I don't think that's allowed.
>
> > Unfortunately the above does not work. What is missing?
>
> What doesn't work?
>
> I would think your
>
> > location = /test/place {
>
> block would work, although not as shown, but I assume you just left
> out the part that normally handles the request. It would handle the
> requests for id=1 and id=3 as before, and it's just the id=2 case that
> gets redirected, right?
>
> Lewis
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx