Home > Backend Development > PHP Tutorial > Analyze the rewriting rules of CI, the CodeIgniter framework, under Nginx_PHP tutorial

Analyze the rewriting rules of CI, the CodeIgniter framework, under Nginx_PHP tutorial

WBOY
Release: 2016-07-21 15:09:53
Original
755 people have browsed it

I recently studied the CI framework and found that the routing function of this framework has a problem under Nginx, reporting a 404 error. Later, I checked the information online and found that PATH_INFO needs to be turned on. PATH_INFO seems to be supported after nginx7.16, you just need to turn it on in the configuration file.
Open the nginx.conf file and add rewrite rules under your virtual host. The code is as follows:

Copy the code The 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/$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;
}
}


http://www.bkjia.com/PHPjc/327188.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327188.htmlTechArticleRecently researched the CI framework and found that the routing function of this framework has a problem under Nginx, reporting a 404 error, and later online After checking the information, I found that PATH_INFO needs to be turned on. It seems to be supported after nginx7.16...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template