<div>thanks!</div><div><br></div><div>my nginx version is 0.8.52, index.html in /home/my_name/tools/nginx/html/ , this is my nginx config:</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><div><br>
</div><div><div> worker_processes 1;</div><div><br></div><div>error_log logs/error.log debug;</div><div>events {</div><div> worker_connections 1024;</div><div>}</div><div>http {</div><div> include mime.types;</div>
<div> default_type application/octet-stream;</div><div> expires 1y;</div><div> sendfile on;</div><div> server {</div><div> listen 8080;</div><div> server_name localhost;</div>
<div> location ~* ^/html/(.+\.html)$ {</div><div> alias /home/my_name/tools/nginx/html/$1;</div><div> if ($request_uri ~ \.(html|htm|shtml)$) {</div><div> expires<span class="Apple-tab-span" style="white-space:pre">        </span> 1h;</div>
<div> }</div><div> }</div><div> error_page 500 502 503 504 /50x.html;</div><div> location = /50x.html {</div><div> root html;</div><div> }</div><div> }</div><div>
}</div>
<div><br></div>and then exec curl -I <a href="http://127.0.0.1:8080/html/index.html">127.0.0.1:8080/html/index.html</a>:</div><div><br></div><div><div>HTTP/1.1 404 Not Found</div><div>Server: nginx/0.8.52</div><div>Date: Mon, 11 Oct 2010 02:24:25 GMT</div>
<div>Content-Type: text/html</div><div>Content-Length: 169</div><div>Connection: keep-alive</div><div><br></div><div>and this is error log:</div><div><br></div><div><div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http request line: "GET /html/index.html HTTP/1.1"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http uri: "/html/index.html"</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http args: ""</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http exten: "html"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http process request header line</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http header: "User-Agent: curl/7.21.1 (i686-pc-linux-gnu) libcurl/7.21.1 OpenSSL/1.0.0a zlib/1.2.5"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http header: "Host: <a href="http://127.0.0.1:8080">127.0.0.1:8080</a>"</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http header: "Accept: */*"</div><div>
2010/10/11 10:24:25 [debug] 8604#0: *1 http header done</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 event timer del: 3: 2568703927</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 rewrite phase: 0</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 test location: "/50x.html"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 test location: ~ "^/html/(.+\.html)$"</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 using configuration "^/html/(.+\.html)$"</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http cl:-1 max:1048576</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 rewrite phase: 2</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http script var</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http script var: "/html/index.html"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http script regex: "\.(html|htm|shtml)$"</div><div>2010/10/11 10:24:25 [notice] 8604#0: *1 "\.(html|htm|shtml)$" matches "/html/index.html", client: 127.0.0.1, server: localhost, request: "GET /html/index.html HTTP/1.1", host: "<a href="http://127.0.0.1:8080">127.0.0.1:8080</a>"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http script if</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 post rewrite phase: 3</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 generic phase: 4</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 generic phase: 5</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 access phase: 6</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 access phase: 7</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 post access phase: 8</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 content phase: 9</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 content phase: 10</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 content phase: 11</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http script copy: "/home/my_name/tools/nginx/html/"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http script capture: "html"</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http filename: "/home/my_name/tools/nginx/html/htmlTTP/1.1</div><div>User-Agent"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 add cleanup: 09C64B40</div><div>2010/10/11 10:24:25 [error] 8604#0: *1 open() "/home/my_name/tools/nginx/html/htm" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /html/index.html HTTP/1.1", host: "<a href="http://127.0.0.1:8080">127.0.0.1:8080</a>"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http finalize request: 404, "/html/index.html?" a:1, c:1</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 http special response: 404, "/html/index.html?"</div>
<div>2010/10/11 10:24:25 [debug] 8604#0: *1 http set discard body</div><div>2010/10/11 10:24:25 [debug] 8604#0: *1 HTTP/1.1 404 Not Found</div></div></div><div><br></div><div>and i remove this line in nginx config :</div>
<div><br></div><div><div> if ($request_uri ~ \.(html|htm|shtml)$) {</div><div> expires<span class="Apple-tab-span" style="white-space: pre; ">        </span> 1h;</div><div> }</div></div><div><br></div><div>and exec curl -I <a href="http://127.0.0.1:8080/html/index.html">127.0.0.1:8080/html/index.html</a>:</div>
<div><br></div><div><div>HTTP/1.1 200 OK</div><div>Server: nginx/0.8.52</div><div>Date: Mon, 11 Oct 2010 02:26:33 GMT</div><div>Content-Type: text/html</div><div>Content-Length: 158</div><div>Last-Modified: Sat, 05 Jun 2010 15:20:23 GMT</div>
<div>Connection: keep-alive</div><div>Expires: Tue, 11 Oct 2011 02:26:33 GMT</div><div>Cache-Control: max-age=31536000</div><div>Accept-Ranges: bytes</div></div><div><br></div>-- <br>博观约取<br><br>豆瓣:<a href="http://www.douban.com/people/mustang/" target="_blank">www.douban.com/people/mustang/</a><br>
<br>blog: <a href="http://www.pagefault.info" target="_blank">www.pagefault.info</a><br><br>twitter: <a href="http://www.twitter.com/minibobo" target="_blank">www.twitter.com/minibobo</a><br>
</div></div>