2013-07-15 48 views
0

我有nginx.conf到fuelphpnginx重写模块不工作?

location/{ 
    if (!-e $request_filename) { 
     rewrite ^(.*)$ index.php?/$1 last; 
    } 
} 

location ~ \.php$ { 
    fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
    fastcgi_index index.php; 
    include  fastcgi.conf; 
    include /etc/nginx/fastcgi_params; 
} 

但这不是testfphp /公/欢迎工作/你好

nginx的说:找不到文件

谢谢。

回答

0

您似乎混合了不同操作方法的不同位,而不理解它们。注意:

rewrite ^(.*)$ index.php?/$1 last; #question mark, typo? 
location ~ \.php$ # matches end of request_uri 
fastcgi_split_path_info ^(.+\.php)(/.+)$; # matches .php followed by a slash 

对于第三条语句来搭配,.php是从来没有在REQUEST_URI的结束,因此该语句将永远不会在这个位置匹配。

从第一条语句中删除问号,从位置中删除美元符号。然后,添加:

fastcgi_param SCRIPT_FILENAME $document_root$ fastcgi_script_name; 
fastcgi_param PATH_INFO $fastcgi_split_pathinfo; 

到位置块。尝试从文档中了解并尝试进一步限制位置块。