I recently studied the CI framework and found that the routing function of this framework is faulty under Nginx. I reported a 404 error. Later I checked the information on the Internet,
You need to enable PATH_INFO. After nginx7.16, it seems that PATH_INFO is supported. You only need to enable it in the configuration file.
Open the nginx. conf file and add rewrite rules under your VM. The Code is as follows:
Copy codeThe Code is as follows:
Server {
Listen 80;
Server_name www.ci.com;
Location /{
Root d:/www/Codeigniter_2.0.1 /;
Index index.html index.htm index. php;
Rewrite ^/$/index. php last;
Rewrite ^ /(?! Index \. php | robots \. txt | images | js | styles) (. *) $/index. php/$1 last;
}
Location ~ ^ (. + \. Php) (. *) $ {
Root D:/www/Codeigniter_2.0.1 /;
Fastcgi_index index. php;
Fastcgi_split_path_info ^ (. + \. php) (. *) $;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Fastcgi_param PATH_INFO $ fastcgi_path_info;
Fastcgi_param PATH_TRANSLATED $ document_root $ fastcgi_path_info;
Fastcgi_pass 127.0.0.1: 9002;
Include fastcgi_params;
}
}