using two if statements together in nginx conf

Igor Sysoev is at rambler-co.ru
Wed Mar 7 00:14:06 MSK 2007


On Tue, Feb 27, 2007 at 03:09:55PM -1000, Andy Triboletti wrote:

> 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 ~* ".*bob.com.*" && $args ~* "12345")    {
>        rewrite ^/things$ /thing.disabled break;
> 
>    }
> 
> 
> So if someone coming from bob.com 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.

Currently, you can not use "&&" inside "if", so there are some workarounds
only (as it was suggested).


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list