How to resolve 404 errors in Nginx and CI frameworks

Source: Internet
Author: User
This article mainly introduces the Nginx and CI appeared 404 error How to solve the relevant information, the need for friends can refer to the following

Recently just learned CI framework, did a simple project, in the local server environment has been tuned, but when deployed to the remote server:

http://example.com/(index.php)/accessible (default controller-class for configuration)

http://example.com/(index.php)/[controller-class]/[controller-method] can not be accessed (prompt 404 error!) )

Finally Baidu Reason:

For/INDEX.PHP/ABC this url,apache and lighttpd will be interpreted as "index.php?abc", and Nginx will consider the content of the ABC file under the directory where the name "index.php" is requested. So CI under nginx does not configure rewrite is not operational, and in Apache and Lighttpd is normal.

Solution (point Bold, focus red):

server {listen; server_name example.com;root/data/wwwroot/example/index index.php index.html index.htm;location ~* \. ( Css|js|swf|htm|jpg|png|gif|json|atlas)? $ {Expires D;add_header Pragma public;add_header cache-control "public";} location/controller-class/{if (!-e $request _filename) {rewrite ^/controller-class/(. *) $/controller-class/index.php ? q= $uri & $args;}} Location ~ \.php$ {fastcgi_pass ...:; fastcgi_index index.php;fastcgi_param script_filename $document _root$fastcgi_ Script_name;fastcgi_param php_value open_basedir= $document _root:/tmp/:/proc/;include fastcgi_params;}

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

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.