comparing two variables

Maxim Dounin mdounin at mdounin.ru
Tue Jun 14 00:12:04 MSD 2011


Hello!

On Mon, Jun 13, 2011 at 03:44:42PM +0800, Mauro Stettler wrote:

> hi
> 
> i wrote a module which is extracting certain values out of a session
> that is stored in memcache and stores it into a variable in my nginx
> config. so this seems to work fine so far.
> 
> now i'm trying to compare $uri with one of these variables and do a
> rewrite accordingly. but it seems that the if that comes from nginx'
> rewrite module cannot only compare a variable with a static string or
> a static regex, but not with another variable.
> 
> is that true?

Yes, regexps must be static.  You may try something like this as a 
workaround:

    set $tmp "$var1:$var2";
    if ($tmp ~* "^(.*):\1$") {
        ...
    }

Maxim Dounin



More information about the nginx mailing list