title: nginx rewrite - files exist but are rewritten
body: <p>i have a php app under <code>/path/</code></p>
  
  <p>everything that doesn't exist (files/directories) needs to be redirected to <code>/path/index.php</code></p>
  
  <pre><code>if (!-e $request_filename)
  {
    rewrite ^/path/(.+)$ /path/index.php last;
  }
  </code></pre>
  
  <p>and everything works apart from the real files, for some reason .css files that exist are still redirected to the index ... eg <code>/path/CSS/style.css</code></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>fixed with <code>rewrite ^/path/(.+)/$ /path/index.php last;</code> because all my urls that need to be re-written end with a trailing slash, but still confusing</p>
  
  <p>nginx.conf</p>
  
  <pre><code>http {
   include       /etc/nginx/mime.types;  
   access_log  /var/log/nginx/access.log;
  
   sendfile        on;
  
   keepalive_timeout  65;
   tcp_nodelay        on;
  
   gzip  on;
   gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  
   include /etc/nginx/conf.d/*.conf;
   include /etc/nginx/sites-enabled/*;
  }
  </code></pre>
  
  <p>full site-enabled/file</p>
  
  <pre><code>server {
    listen  valueyourvote.org.nz:80;
    server_name  valueyourvote.org.nz valueyourvote.co.nz;
  
    if ($http_host != www.valueyourvote.org.nz) {
        rewrite  (.*)  http://www.valueyourvote.org.nz$1;
    }
    access_log  /var/log/nginx/valueyourvote.org.nz.access.log;
    error_log   /var/log/nginx/valueyourvote.org.nz.error.log;
    location / {
      root   /var/www/vote.incode.co.nz/;
      index  index.php index.html index.htm;
    }
  
    if (!-e $request_filename)
    {
      rewrite ^/supercity-2010/(.+)/$ /supercity-2010/index.php last;
    }
  
  
    # Pass all .php files onto a php-fpm/php-fcgi server.
    location ~ \.php$ {
      fastcgi_pass   localhost:9000;
      fastcgi_index  index.php;
  
      include fastcgi_params;
    }
  
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    location ~ /\.ht {
       deny  all;
    }
  }   
  </code></pre>