using two if statements together in nginx conf

Andy Triboletti andy.triboletti at
Wed Feb 28 04:09:55 MSK 2007

Is there a way to use 2 if statements together either nested or in one line
in the nginx config?  Here is what I want to do

For a given location /things I want to check if a query parameter has a
certain value, and I also want to check the referer and if both match then
do a redirect

I tried doing this and a few other things but couldn't figure out how to
chain multiple if statements together.
location = /things {
    if ($http_referer ~* ".**" && $args ~* "12345")    {
        rewrite ^/things$ /thing.disabled break;


So if someone coming from requests things?thing_id=12345 I want to
send them to a disabled page.  I tried checking for the query parameters in
the location definition block but it didn't have the parameters.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list