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!