nginx:try_files不起作用,error_page确实有效

时间:2015-02-03 21:24:14

标签: nginx

在我的根目录中,我有:

index.html
page-not-found/index.html

我的配置如下:

server {
  ...
  root /var/www/www.example.com;

  location / {
    try_files $uri $uri/ /page-not-found/index.html =404;
  }
}

但是当我尝试打开非现有文件时,我会看到默认的404页面,而不是“/page-not-found/index.html”。为什么呢?

我也测试了

error_page 404 = /page-not-found/index.html;

而不是try_files指令,它工作正常。那我的try_files有什么问题?我正在使用nginx 1.6.2。

编辑:调试不显示与try_files相关的任何内容

2015/02/03 22:27:02 [debug] 10908#0: *1197 http filename: "/var/www/www.example.com/adsds"
2015/02/03 22:27:02 [debug] 10908#0: *1197 add cleanup: 0000000002197148
2015/02/03 22:27:02 [error] 10908#0: *1197 open() "/var/www/www.example.com/adsds" failed (2: No such file or directory), client: x.x.x.x, server: www.example.com, request: "GET /adsds HTTP/1.1", host: "www.example.com"
2015/02/03 22:27:02 [debug] 10908#0: *1197 http finalize request: 404, "/adsds?" a:1, c:1
2015/02/03 22:27:02 [debug] 10908#0: *1197 http special response: 404, "/adsds?"

0 个答案:

没有答案