Nginx 未正确重定向

Nginx 未正确重定向

我从 Nginx 开始,自从 Apache 换成 Nginx 后,我遇到了很多问题。现在我有一个用 Symfony1.4 开发的应用程序,由于出现错误,它无法运行404 Not Found。以下是错误日志:

 2014/02/07 21:28:49 [error] 2091#0: *22 open()
 "/var/www/html/apps/monitor/web/index.php/login" failed (20: Not a
 directory), client: 192.168.3.1, server: devserver, request: "POST
 /apps/monitor/web/index.php/login HTTP/1.1", host: "devserver",
 referrer: "http://devserver/apps/monitor/web/" 2014/02/07 21:29:11
 [error] 2091#0: *22 open() "/var/www/html/apps/monitor/web/login"
 failed (2: No such file or directory), client: 192.168.3.1, server:
 devserver, request: "GET /apps/monitor/web/login HTTP/1.1", host:
 "devserver"

/etc/nginx/conf.d/default.conf这是我的文件的内容:

server {
    listen       80;
    server_name  devserver;
    root   /var/www/html;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        index  index.php;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

怎么了?

添加try_files指令

我添加了try_files以下内容但并没有解决我遇到的问题:

try_files $uri $uri/ /index.php?$args;

EDIT2:尝试另一种方式,得到 500 服务器错误

我尝试了另一种替代方法:

索引 index.php app.php index.html index.htm;

try_files $uri $uri/ @rewrite;

location @rewrite {
   rewrite ^/(.*)$ /index.php/$1;
}

location ~ \.php$ {
    fastcgi_index app.php;
    fastcgi_pass 127.0.0.1:9000;

    include fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

但日志上说了这样的话:

2014/02/07 22:06:11 [error] 2905#0: *2 rewrite or internal redirection cycle while internally redirecting to "/apps/monitor/web/index.php/login", client: 192.168.3.1, server: devserver, request: "GET /apps/monitor/web/index.php/login HTTP/1.1", host: "devserver"

相关内容