title: nginx redirect loop, index.html
body: <p>This seems ridiculous but I've not found a working answer in over an hour of searching.
  When I access "<a href="http://oa.wechat.com/screen/index.html" rel="nofollow">http://oa.wechat.com/screen/index.html</a>", it will cause a 301 redirect loop, like this:</p>
  
  <pre><code>"GET /screen/ HTTP/1.1" 301
  "GET /screen/index.html/ HTTP/1.1" 301 
  "GET /screen/index.html/index.html/ HTTP/1.1" 301 
  ... 
  </code></pre>
  
  <p>nginx verson: 1.5.6
  nginx.conf</p>
  
  <pre><code>    server {
          listen  80;
          server_name oa.wechat.com;
  
          location ~ ^/screen/ {
              alias /data/screen/static/;
              index index.html;
          }  
      } 
  </code></pre>
  
  <p>Could anyone tell me the reason? Thanks very much.</p>
  
  <p>i have checked nginx document. the right usage of 'alias':</p>
  
  <pre><code>    # use normal match like this
      location  /i/ {
        alias  /spool/w3/images/;
      }
  
      # use regex match like this
      location ~ ^/download/(.*)$ {
        alias /home/website/files/$1;
      }
  </code></pre>
  
  <p>the wrong way to use 'alias' is:</p>
  
  <pre><code>    location ~ ^/screen/ {
          alias /data/screen/static/;
          index index.html;
      }  
  </code></pre>
  
  <p>In this case, the request would be considered as a directory request, not file request, which will lead a redirect loop.</p>
  
  <p>Anyway, Thanks Flesh very much!</p>