rewritecond for nginx

Chris Cortese at
Fri Feb 27 14:44:51 MSK 2009

I think I figured out the answer to my last question about perl CGI.  I 
put the path to cgi-bin in the fastcgi_params file.

I have another question:

How can I tell nginx to not rewrite certain directories?  I use the 
RewriteCond in Apache.  I googled for the answer and I read that I 
should use "if" conditions.  But I'm still not totally clear.  I'm using 
rewrite on most of my php code with:

    if (!-e $request_filename) {
      rewrite ^/(.*)$ /index.php?q=$1 last;

...and that works fine..   now I just want to say:  Don't do any rewrite 
for directories named /tmp, /filestore, and /cgi-bin.

I tried the following, thinking that the rewrite rule would accomplish 
nothing other than telling nginx not to use any subsequent rewrite 
rules.  It looks crazy but it's all I could come up with:

 if ($request_filename ~ (tmp|filestore|cgi-bin)) {
    rewrite ~/(.*)$ /$1 last;

I put those 3 lines before the other 3 lines up above.

What should I have instead?


More information about the nginx mailing list