codeigniter nginx rewrite

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

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

贴上自己的配置:

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;
        }
 }
}

你可能感兴趣的:(codeigniter nginx rewrite)