How to do location /test/place?id=2
P.V.Anthony
anthony at mindmedia.com.sg
Fri Oct 18 04:00:12 UTC 2019
On 18/10/19 5:15 am, J. Lewis Muir wrote:
> 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.
Noted. I will change that.
>> 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.
Yah. Sad.
>> Unfortunately the above does not work. What is missing?
>
> What doesn't work?
I was hoping to get location = /test/place?id=2 { to work. Like you have
mentioned, it is not allowed.
> 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?
That is where I need help with. I need help with requests for id=1 and
id=3. I need them to just pass through without any changes. I only need
id=2 to be redirected and id=2 redirection is working. I cannot figure
out how to pass through id=1 and id=3.
With the follow block id=1 and id=3 gives a 404 error.
location = /test/place {
if ($args = "id=2") {
return 301 https://new.example.com/test/place?$args;
}
}
How to make id=1 and id=3 to work?
P.V.Anthony
More information about the nginx
mailing list