<div dir="ltr"><div>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? <a href="https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/">https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/</a></div><div><br></div><div>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?</div><div><br></div><div>Random thoughts waiting for things to compile<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 17, 2019 at 5:15 PM J. Lewis Muir <<a href="mailto:jlmuir@imca-cat.org">jlmuir@imca-cat.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 10/18, P.V.Anthony wrote:<br>
> Currently have the following url,<br>
> <br>
> <a href="https://old.example.com/test/place?id=1" rel="noreferrer" target="_blank">https://old.example.com/test/place?id=1</a><br>
> <a href="https://old.example.com/test/place?id=2" rel="noreferrer" target="_blank">https://old.example.com/test/place?id=2</a><br>
> <a href="https://old.example.com/test/place?id=3" rel="noreferrer" target="_blank">https://old.example.com/test/place?id=3</a><br>
> <br>
> Need to redirect only id=2 to another url.<br>
> <br>
> Did the following and it works for id=2. Need id=1 and id=3 to continue<br>
> normally without change.<br>
> <br>
> location = /test/place {<br>
> if ($args = "id=2") {<br>
> return 301 <a href="https://new.example.com/test/place?$args" rel="noreferrer" target="_blank">https://new.example.com/test/place?$args</a>;<br>
> }<br>
> }<br>
<br>
You might want to use $arg_id here (i.e., the $arg_<name> variable for<br>
the <name> argument). Otherwise, it won't work if any other arguments<br>
are given.<br>
<br>
> Or is there a way to do the following? That would be ideal.<br>
> <br>
> location = /test/place?id=2 {<br>
> return 301 <a href="https://new.example.com/test/place?id=2" rel="noreferrer" target="_blank">https://new.example.com/test/place?id=2</a><br>
> }<br>
<br>
I don't think that's allowed.<br>
<br>
> Unfortunately the above does not work. What is missing?<br>
<br>
What doesn't work?<br>
<br>
I would think your<br>
<br>
> location = /test/place {<br>
<br>
block would work, although not as shown, but I assume you just left<br>
out the part that normally handles the request. It would handle the<br>
requests for id=1 and id=3 as before, and it's just the id=2 case that<br>
gets redirected, right?<br>
<br>
Lewis<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div>