codeigniter nginx rewrite

CI框架在nginx服務器上配置rewrite去掉index.php的方法: php

打開/usr/local/etc/nginx/ 目錄下的配置文件xxx.conf, nginx

貼上本身的配置: 服務器

server
{
    listen       80;
    server_name  cc.ecjtu.net;
    index index.php;
    root  /www/cyrec;
//下面一段是nginx模擬pathinfo,不然CI框架的控制器沒法訪問
    location ~ .*.php($|/)
    {
        root /www/cyrec;
        fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        include fastcgi_params;
      fastcgi_pass unix:/tmp/php-fcgi.sock;
      fastcgi_index index.php;
      include fcgi.conf;
}
//下面就是rewirte去index.php
location / {
        if (!-e $request_filename) {
        rewrite ^/(.*)$ /index.php/$1 last;
        }
 }
}
相關文章
相關標籤/搜索