How does the CodeIgniter framework rewrite rules under Nginx?
This article will explain in detail how the CodeIgniter framework rewrites rules under Nginx. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
Recently, I studied CI framework and found that the routing function of this framework has problems under Nginx, reporting 404 errors. Later, I checked the information on the Internet.
Found need to open PATH_INFO. PATH_INFO seems to be supported after nginx 7.16, just open it in the configuration file.
Open the nginx.conf file and add the rewrite rule to your virtual host, 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/$1last;
}
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;
}
}
About "CodeIgniter framework in Nginx rewrite rules is how" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.