Nginx fastcgi找不到404

时间:2016-04-17 20:20:11

标签: nginx fastcgi

我的网址是/ web / html / pub。 $ MAGE_ROOT = / web / html

以下是nginx conf的示例。

root $MAGE_ROOT/pub;
index index.php;
autoindex off;
charset off;
location /pub {
    root $MAGE_ROOT;

    location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
        deny all;
    }

    add_header X-Frame-Options "SAMEORIGIN";
}
location ~ (index|info|get|static|report|404|503)\.php$ {
    try_files $uri =404;
    fastcgi_pass   fastcgi_backend;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

这是我的调试错误日志。

2016/04/17 20:58:24 [debug] 4856#6680: *1 http script var: "html/magento202"
2016/04/17 20:58:24 [debug] 4856#6680: *1 open index "c:\web\nginx/html/magento202/pub/index.php"
2016/04/17 20:58:24 [debug] 4856#6680: *1 internal redirect: "/pub/index.php?"
2016/04/17 20:58:24 [debug] 4856#6680: *1 rewrite phase: 1
2016/04/17 20:58:24 [debug] 4856#6680: *1 http script value: "html/magento202"
2016/04/17 20:58:24 [debug] 4856#6680: *1 http script set $mage_root
2016/04/17 20:58:24 [debug] 4856#6680: *1 http script value: "developer"
2016/04/17 20:58:24 [debug] 4856#6680: *1 http script set $mage_mode
2016/04/17 20:58:24 [debug] 4856#6680: *1 test location: "/"
2016/04/17 20:58:24 [debug] 4856#6680: *1 test location: "setup"
2016/04/17 20:58:24 [debug] 4856#6680: *1 test location: "pub"
2016/04/17 20:58:24 [debug] 4856#6680: *1 test location: ~ "^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml)"
2016/04/17 20:58:24 [debug] 4856#6680: *1 test location: ~ "(index|info|get|static|report|404|503)\.php$"
2016/04/17 20:58:24 [debug] 4856#6680: *1 using configuration "(index|info|get|static|report|404|503)\.php$"
2016/04/17 20:58:24 [debug] 4856#6680: *1 http cl:-1 max:1048576
2016/04/17 20:58:24 [debug] 4856#6680: *1 rewrite phase: 3
2016/04/17 20:58:24 [debug] 4856#6680: *1 post rewrite phase: 4
2016/04/17 20:58:24 [debug] 4856#6680: *1 generic phase: 5
2016/04/17 20:58:24 [debug] 4856#6680: *1 generic phase: 6
2016/04/17 20:58:24 [debug] 4856#6680: *1 generic phase: 7
2016/04/17 20:58:24 [debug] 4856#6680: *1 access phase: 8
2016/04/17 20:58:24 [debug] 4856#6680: *1 access phase: 9
2016/04/17 20:58:24 [debug] 4856#6680: *1 access phase: 10
2016/04/17 20:58:24 [debug] 4856#6680: *1 post access phase: 11
2016/04/17 20:58:24 [debug] 4856#6680: *1 try files phase: 12
2016/04/17 20:58:24 [debug] 4856#6680: *1 http script var: "html/magento202"
2016/04/17 20:58:24 [debug] 4856#6680: *1 http script copy: "/pub"
2016/04/17 20:58:24 [debug] 4856#6680: *1 http script var: "/pub/index.php"
2016/04/17 20:58:24 [debug] 4856#6680: *1 trying to use file: "/pub/index.php" "c:\web\nginx/html/magento202/pub/pub/index.php"
2016/04/17 20:58:24 [debug] 4856#6680: *1 trying to use file: "=404" "c:\web\nginx/html/magento202/pub=404"
2016/04/17 20:58:24 [debug] 4856#6680: *1 http finalize request: 404, "/pub/index.php?" a:1, c:2
2016/04/17 20:58:24 [debug] 4856#6680: *1 http special response: 404, "/pub/index.php?"
2016/04/17 20:58:24 [debug] 4856#6680: *1 http set discard body
2016/04/17 20:58:24 [debug] 4856#6680: *1 HTTP/1.1 404 Not Found

对于我的生活,我无法弄清楚为什么当我尝试去http://domain/pub/时nginx将“pub”插入到网址中两次。我有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您的location /pub尝试通过应用继承的/pub/指令来解析URI index,并将URI重写为/pub/index.php

现在,任何以.php结尾的URI都由location ~ (index|info|get|static|report|404|503)\.php$块处理。

在此块中,(继承的)根被定义为.../pub,它以URI为前缀:.../pub/pub/index.php