title: Silly nginx rewrite issue - infinate loop
body: <p>I'm totally baffled with this one. Its probably something silly, and I'm missing it after along day! Anyway, I have this rewrite rule setup in my nginx config for the site:</p>
  
  <pre><code>location / {
      root   /srv/www/site.co.uk/www;
      index  index.html index.htm index.php;
  
      rewrite ^/(.*)/index.html$ http://site.co.uk/$1/ permanent;
      rewrite ^/index.html$ http://site.co.uk/ permanent;
  }
  </code></pre>
  
  <p>When I go to:</p>
  
  <ul>
  <li><a href="http://www.example.com/index.html" rel="nofollow">http://www.example.com/index.html</a></li>
  <li><a href="http://www.example.com/foo/index.html" rel="nofollow">http://www.example.com/foo/index.html</a></li>
  </ul>
  
  <p>..then it correctly sends to:</p>
  
  <ul>
  <li><a href="http://www.example.com/" rel="nofollow">http://www.example.com/</a></li>
  <li><a href="http://www.example.com/foo/" rel="nofollow">http://www.example.com/foo/</a></li>
  </ul>
  
  <p>If I comment those 2 rewrite rules out, restart nginx, then retry... the page loads fine!</p>
  
  <p>Can anyone see where I'm going wrong? Maybe I'm just being blind!</p>