nginx 1.0.10 error [emerg] invalid condition "'!-f"

Maxim Dounin mdounin at mdounin.ru
Thu Jul 12 07:15:50 UTC 2012


Hello!

On Thu, Jul 12, 2012 at 03:09:52AM -0400, google000 wrote:

> I have that kind of code which I wanna add to my nginx conf but
> unfortunately something is wrong and I don't know how to fix it...
> 
> location ^~ /folder/ {
>            if ($cookie_amember_nr !~* [a-zA-Z0-9]+) { #no identity
>                rewrite ^(.*)$
> http://localhost/am3/plugins/protect/new_rewrite/login.php?v=-2,1&url=$request_uri?$args
> redirect;
>            }
>            set $file1
> $document_root/am3/data/new_rewrite/$cookie_amember_nr-1;
>            set $file2
> $document_root/am3/data/new_rewrite/$cookie_amember_nr-2;
> 
>            if (!-f $file1 && !-f $file2) { #has not access
>                rewrite ^(.*)$
> http://localhost/am3/plugins/protect/new_rewrite/login.php?v=-2,1&url=$request_uri?$args
> redirect;
>            }
> 
>         }
> 
> 
> and I've got an error in line with : if (!-f $file1 && !-f $file2) {
> #has not access
> 
> error : "[emerg] invalid condition "'!-f"
> 
> how to fix this ?

There is no support for the "&&" operator, hence the expression 
written is invalid.

http://nginx.org/r/if

Maxim Dounin



More information about the nginx mailing list