CodeIgniter在nginx下404 not found

server {

        listen       80;
        server_name  test.platform;
        charset utf8;
        root  /data/www/platform/trunk;

        location / {
            index index.html index.php;
        }   
        
         location ~ \.php($|/) {
            
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param   PATH_INFO $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param    PATH_TRANSLATED    $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }   
        
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }   


        access_log  /usr/local/nginx/logs/test.platform.access.log;
        error_log  /usr/local/nginx/logs/test.platform.error.log;
    }
复制代码

 修改nginx的server如上面,就ok了,该问题捯饬了一天,才搞定;

需要注意的地方:

 location ~ \.php($|/) {

一开始我的配置为:
 location ~ \.php$ {  所以一直没有搞成功,这个问题折腾了很久,特此说明一下。


 找到php的php.ini文件(可能在php安装目录的etc目录也可能在lib文件夹下,看自己的配置),搜索:cgi.fix_pathinfo  将注释放开,并置为1:cgi.fix_pathinfo=1
参考地址: http://www.chenyudong.com/archives/codeigniter-in-nginx-and-url-rewrite.html http://haiker.iteye.com/blog/917413 http://blog.csdn.net/ei__nino/article/details/8599304 http://codeigniter.org.cn/forums/forum.php?mod=viewthread&tid=11791 http://qing.tiyee.net/post/2012-11-18/40041056531 (好东西,值得学习)

你可能感兴趣的:(nginx)