CodeIgniter在nginx下404 not found

CodeIgniter是一套輕量級php框架,最近在學習這套框架。php

從官網上下載了3.0版本配置在服務器上測試,個人配置環境是centos+nginx+php+mysql。html

我將CI配置到服務器後,發現默認控制器老是能夠正常訪問的,把默認控制器的指向改爲其餘控制器也均可以訪問,可是用頁面裏的連接或者直接url裏手動輸入就會報404。mysql

查閱資料後才知道CI在nginx下運行是要配置一下,個人配置以下nginx

 server {
        listen       80;
        server_name  test;
        
        location / {
            index index.html index.php;root  
            /data/www/test;
        }   
        
         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;
    }

 如上修改server就能夠正常運行了web

須要注意的地方:sql

location ~ \.php($|/) {
 一開始個人配置爲:
location ~ \.php$ {  因此一直沒有搞成功,這個問題折騰了好久,特此說明一下。
參考地址:http://www.chenyudong.com/archives/codeigniter-in-nginx-and-url-rewrite.htmlhttp://haiker.iteye.com/blog/917413http://blog.csdn.net/ei__nino/article/details/8599304http://codeigniter.org.cn/forums/forum.php?mod=viewthread&tid=11791http://qing.tiyee.net/post/2012-11-18/40041056531 (好東西,值得學習)
相關文章
相關標籤/搜索