title: Rewriting URI within Nginx
body: <p>Im trying to get URI Routing set up for my framework and im currently working on nginx as teh server, but the problem is i keep getting 500 error when trying to access either one of the following links</p>
  
  <ul>
  <li><code>http://localhost.framework/</code></li>
  <li><code>http://localhost.framework/index.php/</code></li>
  </ul>
  
  <p>If I access the site using the following links it works:</p>
  
  <ul>
  <li><code>http://localhost.framework/index.php</code></li>
  <li><code>http://localhost.framework/index.php?/</code></li>
  </ul>
  
  <p>my configuration for the domain is as follows:</p>
  
  <pre><code>server {
      listen 80;
      server_name localhost.framework;
      root   /var/www/ASFramework;
  
      access_log  /var/log/nginx/framework.access.log;
      error_log  /var/log/nginx/framework.error.log;
  
      location / {
          rewrite ^/(.*)$ /index.php/$1 last;
      }
  
          location ~ \.php$ {
                  fastcgi_pass   127.0.0.1:9000;
                  fastcgi_index  index.php;
          include        fastcgi_params;
                  fastcgi_param  SCRIPT_FILENAME  /var/www/ASFramework$fastcgi_script_name;
          }
  }
  </code></pre>
  
  <p>basically what im trying to do is take the following url</p>
  
  <ul>
  <li><code>http://localhost.framework/controller/method/../</code></li>
  </ul>
  
  <p>and rewrite it to:</p>
  
  <ul>
  <li><code>http://localhost.framework/index.php/controller/method/../</code></li>
  </ul>
  
  <p>Within the logs <code>(error.log)</code> is:</p>
  
  <pre><code>2011/07/03 22:57:22 [error] 19837#0: *6 rewrite or internal redirection cycle while processing "/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/", client: 127.0.0.1, server: localhost.framework, request: "GET / HTTP/1.1", host: "localhost.framework"
  </code></pre>
  
  <p>Can anyone tell me what's going on and how I can fix it?</p>