I am trying to achieve a redirection in nginx that should happen only if a specific argument and value pair is existing.
For example : https://www.mywebsite.com/search?abc=453?hjh=7484?foo=bar?joe=blah
should be proxied to an application only if hjh=7484 is present in the request_uri. This can be anywhere in the whole URL, that said its position is not fixed.
If the incoming request against search page doesn't have hjh=7484 the request should be redirected to https://www.mynewwebsite.com/
I have tried putting
location ~* /search(.*)?hjh=7484(.*)?$ {
proxy_pass $my_app;
}
Above is ending in 404.
2019/01/21 15:48:47 [error] 113#113: *109 open() "/usr/share/nginx/html/search" failed (2: No such file or directory),
If I change the above regex and allow any requests to search page to be passed its working!