'NGINX rewrite rule using two variables

I would like to achieve this but don't know how, or if it is possible:

web.com/anything => if web.com/show.php?query=anything

web.com/anything/something => if web.com/show.php?query=anything&query2=something

I mean , if there's only one variable it rewrites to web.com/variable

If there's a second variable, the first one turns into a folder now => web.com/variable/variable2



Solution 1:[1]

Just did it !!

Was more simple that I've imagined..

rewrite ^/([a-zA-Z]+)/([a-zA-Z]+)$ show.php?query=$1&query2=$2 last;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1