CodeIgniter框架在Nginx下的重写规则

  1. 打开nginx.conf文件,在你的虚拟主机下增加重写规则,代码如下: 

  2.  

  3. server { 

  4.         listen       80; 

  5.         server_name    www.ci.com; 

  6.         location / { 

  7.             root   d:/www/Codeigniter_2.0.1/; 

  8.             index  index.html index.htm index.php; 

  9.         rewrite ^/$ /index.php last; 

  10.         rewrite ^/(?!index\.php|robots\.txt|images|js|styles)(.*)$ /index.php/$1 last; 

  11.         } 

  12.     location ~ ^(.+\.php)(.*)$ { 

  13.         root       D:/www/Codeigniter_2.0.1/; 

  14.         fastcgi_index    index.php; 

  15.         fastcgi_split_path_info ^(.+\.php)(.*)$; 

  16.         fastcgi_param    SCRIPT_FILENAME    $document_root$fastcgi_script_name; 

  17.         fastcgi_param    PATH_INFO        $fastcgi_path_info; 

  18.         fastcgi_param    PATH_TRANSLATED    $document_root$fastcgi_path_info; 

  19.         fastcgi_pass    127.0.0.1:9002; 

  20.         include    fastcgi_params; 

  21.     } 


你可能感兴趣的:(CodeIgniter框架在Nginx下的重写规则)