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

2019-10-19 Thread P.V.Anthony
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

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

2019-10-18 Thread P.V.Anthony
On 18/10/19 9:47 pm, J. Lewis Muir wrote: And in your example, you were doing a return inside an "if" which is noted as being safe in a location context. Phew! Thank you for the advice. P.V.Anthony ___ nginx mailing list nginx@nginx.org

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

2019-10-18 Thread P.V.Anthony
On 18/10/19 2:59 pm, Patrick wrote: The `if' part should be fine. The problem would be someone crafting a URL that skips past the `=' check and yet is still parsed as `id=2' by the underlying app. Can the underlying old app also be changed to log an attack, and throw a 444 when it gets an `id'

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

2019-10-18 Thread J. Lewis Muir
On 10/18, P.V.Anthony wrote: > On 18/10/19 5:26 am, Jeff Dyke wrote: > > 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/ > > > >

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

2019-10-18 Thread Patrick
On 2019-10-18 13:57, P.V.Anthony wrote: > Like netsec and using "if" in the config. The `if' part should be fine. The problem would be someone crafting a URL that skips past the `=' check and yet is still parsed as `id=2' by the underlying app. Can the underlying old app also be changed to log

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

2019-10-17 Thread P.V.Anthony
On 18/10/19 1:33 pm, Patrick wrote: Awesome. By `safe' do you mean netsec, or memory-safe, or ? Like netsec and using "if" in the config. I suppose for my case, I have to use "if". Thank you very much for helping to solve this. I was cracking my head on how to solve this. You really

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

2019-10-17 Thread Patrick
On 2019-10-18 13:17, P.V.Anthony wrote: > Tried the following and it works but is it safe? > > if ( $request_uri = "/test/place?id=2" ) { > rewrite ^ http://new.example.com${uri}?${args}? last; > } Awesome. By `safe' do you mean netsec, or memory-safe, or ? Patrick

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

2019-10-17 Thread P.V.Anthony
On 18/10/19 12:20 pm, Patrick wrote: Without a map, try starting with: if ( $uri?$args = /test/place?id=2 ) { rewrite ^ http://new.example.com/${uri}?${args}? last; } Then as the site migration continues turn that `if' test into a regexp that will match the migrated components. I can

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

2019-10-17 Thread Patrick
On 2019-10-18 12:12, P.V.Anthony wrote: > I am using ispconfig web control that only allows changes in the server > block. Without a map, try starting with: if ( $uri?$args = /test/place?id=2 ) { rewrite ^ http://new.example.com/${uri}?${args}? last; } Then as the site migration continues

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

2019-10-17 Thread P.V.Anthony
On 18/10/19 9:03 am, Patrick wrote: This looks like a gradual migration of content to a new server. Try using `rewrite' instead of `return'? map "$uri?$args" $is_new_site { /test/place?id=2 1; default 0; } server { ... if ( $is_new_site ) { rewrite

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

2019-10-17 Thread P.V.Anthony
On 18/10/19 5:26 am, Jeff Dyke wrote: 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

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

2019-10-17 Thread P.V.Anthony
On 18/10/19 5:15 am, J. Lewis Muir wrote: You might want to use $arg_id here (i.e., the $arg_ variable for the 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 =

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

2019-10-17 Thread Patrick
On 2019-10-18 01:01, 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. This looks like a gradual migration of content

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

2019-10-17 Thread Jeff Dyke
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

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

2019-10-17 Thread J. Lewis Muir
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

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

2019-10-17 Thread P.V.Anthony
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