码迷,mamicode.com
首页 > 其他好文 > 详细

CI 在nginx中出现404错误的解决方式

时间:2014-09-21 02:42:09      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   ar   文件   div   sp   问题   

因为你的nginx配置的是截取.php文件后缀的访问转发到PHP-CGI,而index.php和index.php/是不一样的。。 你在nginx里面写一句:

 if (!-e $request_filename) {
      rewrite ^.*$ /index.php last;
    }
//出现的问题 用这个解决了,

 

NGINX 默认不支持 PATH_INFO 模式,需要修改NGINX配置 让NGINX 来解析 index.php/controller/f 这种模式 具体配置:

#CI
server {
        listen      80;
        server_name www.ci.com;
        index       index.php index.html index.htm;
        root        "/servers/apps/CI";
      location ~ \.php{
       fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
            ##########################################pathinfo 模式
            set $path_info "";
            set $real_script_name $fastcgi_script_name;
            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$"){
                 set $real_script_name $1;
                 set $path_info $2;
            }
            include fastcgi.conf;
            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;
            ##########################################nginx支持pathinfo 模式的重点    

       }      
}

 

CI 在nginx中出现404错误的解决方式

标签:style   blog   color   io   ar   文件   div   sp   问题   

原文地址:http://www.cnblogs.com/hubing/p/3984002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!