Parse CI: rewrite rules of CodeIgniter framework under Nginx

Source: Internet
Author: User
Tags codeigniter

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.