存档

文章标签 ‘kohana3’

kohana3在nginx中的重写配置

2011年7月18日 effect 没有评论

在公司内部推广过kohana3,反应还算可以。不过有好几次同事来咨询在nginx下的重写配置,下面作为备忘:

 location / {
         root   /data/vhosts/k3.com/public_html;#这里改为你对应的目录
         index  index.php index.html index.htm;
          if (!-e $request_filename) {
                rewrite ^/(.*)$ /index.php/$1 last;
          }
        }
 
        location ~ ^(.+\.php)(.*)$  {
                root /data/vhosts/k3.com/public_html;#这里改为你对应的目录
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                set $script $fastcgi_script_name;
            if ($uri ~ "^/index.php(/.+)$") {  ###这个if语句表示如果是如果是以/index.php开头的URL,那么设置sectip为index.php path_info为后面部分
                set $script 'index.php';
                set $path_info  $1;<span style="color: #800000;">###这一行很重要</span>
            }
                fastcgi_param SCRIPT_FILENAME /data/vhosts/k3.com/public_html/$fastcgi_script_name;#这里改为你对应的目录
                fastcgi_param  PATH_INFO $path_info;<span style="color: #800000;">###这一行也很重要 在kohana3中是使用path_info来做route</span>
                include fastcgi_params;
        }

kohana3是一个简单高效的PHP5框架,拥有良好的OO特性,很强的扩展性(非修改源码方式来扩展,在这里小小的BS一下总是想通过修改源码来达到扩展目的的同学),强烈推荐!

分类: php 标签: