【问题标题】:nginx rewrite module not working?nginx重写模块不起作用?
【发布时间】:2013-07-17 00:59:13
【问题描述】:

我有 nginx.conf 到fuelphp

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/public/welcome/hello

nginx 说:找不到文件

谢谢。

【问题讨论】:

    标签: nginx


    【解决方案1】:

    您似乎混合了来自不同操作方法的不同部分,但没有理解它们。观察:

    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;
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      相关资源
      最近更新 更多