Nginx中CI的重写配置

网上大概搜索了下  说是

codeigniter的url rewrite也是使用pathinfo来实现的,需要借助fastcgi_split_path_info来设置$_SERVER['PATHINFO']

至于具体的配置,还是得根据自己的实际环境来小做修改吧


这边附上一份 我自己测试用的 server 配置

server
{
    listen    80;
    server_name   ci.test.com;
    root /jeen/html/citest;
        #排除一些目录及文件 其他全部重写到 index.php
    if ($request_uri !~* (^\/$|\/(favicon\.ico|css|js|page_err|p_w_picpaths|cache|chart|upload|plugin|staticFiles|pic|robots\.txt|index\.php)))
    {
        rewrite ^/(.*)$ /index.php/$1 break;
    }
    location ~ .*\.php?($|/)
    {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include        fastcgi.conf;
        set $script "/index.php";
        set $path_info "";
        if ($uri ~* "^\/(.+?\.php)(/.*)$")
        {
            set $script $1;
            set $path_info $2;
        }
        fastcgi_param SCRIPT_NAME /$script;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param SCRIPT_FILENAME    $document_root/$script;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|ico)$
    {
        access_log off;
        expires 30d;
    }
}


以上就是在测试过程中使用的咯

主要就是 server_name  和 root  以及 排除重写的一些目录和文件

ci.test.com 在hosts文件中添加相关的记录就ok咯  这边就不赘述了




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章