Nginx location to match query parameters

Posted by Dave on Server Fault See other posts from Server Fault or by Dave
Published on 2012-10-12T08:23:21Z Indexed on 2012/10/12 9:40 UTC
Read the original article Hit count: 250

Filed under:
|
|
|

Is it possible in nginx to have a location {} block that matches query parameters. For example I want to pick up that "preview=true" in this url and then instruct it to do several different things, all possible in a location block.

    http://192.158.0.1/web/test.php?hello=test&preview=true&another=var

The problem I'm having is that my test stuff doesn't seem to match, it seems like I can only match the URL itself?

E.g.

location ~ ^(.*)(preview)(.*)$

Or something aloong those lines?

© Server Fault or respective owner

Related posts about nginx

Related posts about proxy