全球主机交流论坛

标题: 求助nginx问题 [打印本页]

作者: gdtv    时间: 2009-12-17 11:48
标题: 求助nginx问题
nginx怎么才能支持index.php/id/2这样的路径呢?
现在只支持index.php?/id/2
作者: qwe123    时间: 2009-12-17 12:09
可能需要定义一个 pathinfo吧
作者: greensnow    时间: 2009-12-17 12:13
rewrite ^(.*\.php)/(id)/([0-9]*)$ $1?$2=$3 last;

[ 本帖最后由 greensnow 于 2009-12-17 12:17 编辑 ]
作者: gdtv    时间: 2009-12-17 12:31
标题: 回复 3# 的帖子
我的问题是,不用rewrite,怎样让系统默认就支持index.php/id/2
作者: qwe123    时间: 2009-12-17 12:48
解决方法有两种:
1 不用pathinfo 改为request_uri
2 照着下面这个网站改配置文件
http://hi.baidu.com/dain_sun/blo ... 100bda63d98681.html
作者: wzwen    时间: 2009-12-17 13:29
楼主用的是框架吧。。。

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                #fastcgi_pass  127.0.0.1:9000;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }


替换成


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

    location ~ .php$ {
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include      fastcgi_params;
    }

    location ~ \.php($|/) {

        set $script     $uri;
        set $path_info  "";

        if ($uri ~ "^(.+\.php)(/.+)") {
            set $script     $1;
            set $path_info  $2;
        }

作者: wzwen    时间: 2009-12-17 13:32
看我的完整版。。。
http://fd.vvwvv.eu.org/thread-6718-2-1.html
作者: cpuer    时间: 2009-12-17 13:48
标题: 回复 7# 的帖子

作者: gdtv    时间: 2009-12-17 13:57
多谢楼上几位

网上铺天盖地的文章说到设置url rewrite为  ^(.*)$ index.php/$1
却没有提到nginx默认不支持pathinfo,
网上的的文章真是害死人
作者: qwe123    时间: 2009-12-17 14:06
标题: 回复 9# 的帖子
你用的框架吧? fleaphp thinkphp 还是codeigniter?或cake 、zend framework ? 里面应该有设置的,可以启用request_uri或其它方式,不一定非得pathinfo啊。
作者: wzwen    时间: 2009-12-17 14:08
标题: 回复 10# 的帖子
其他 方式是可以,比如thinkphp可以设置兼容模式,但不喜欢那种url

还是pathinfo的路径美观。。。。
作者: qwe123    时间: 2009-12-17 14:11
标题: 回复 11# 的帖子
这个不太清楚,反正我用codeigniter的时候设置成request_uri后路径是和pathinfo一模一样的
作者: gdtv    时间: 2009-12-17 14:16
原帖由 qwe123 于 2009-12-17 14:06 发表
你用的框架吧? fleaphp thinkphp 还是codeigniter?或cake 、zend framework ? 里面应该有设置的,可以启用request_uri或其它方式,不一定非得pathinfo啊。

是codeigniter
现在设置成AUTO模式,url rewrite 设置成index.php?$1
可以了




欢迎光临 全球主机交流论坛 (https://fd.vvwvv.eu.org/) Powered by Discuz! X3.4