Error 404 in Nginx + CI framework

Source: Internet
Author: User

Error 404 in Nginx + CI framework

Recently I just learned the ci framework and made a simple project. All the local Nginx server environments have been called, but when I deploy it to a remote server:

Http://example.com/(index. php)/accessible (for the default controller-class configured)

Http://example.com/(index. php)/[controller-class]/[controller-method] inaccessible (Error 404 !)

Nginx + CI Error 404

Cause:

For URLs such as/index. php/abc, Apache and Lighttpd press "index. php? Nginx considers the content of the abc file under the "index. php" directory as the Request Name. Therefore, CI cannot run without configuring rewrite in nginx, but is normal in Apache and Lighttpd. Solution (bold points, highlighted in red ):

1 server {
2 listen 80;
3 server_name example.com;
4 root/data/wwwroot/example/5 index. php index.html index.htm;
6
7 location ~ * \. (Css | js | swf | htm | jpg | png | gif | json | atlas )? $ {
8 expires 1d;
9 add_header Pragma public;
10 add_header Cache-Control "public ";
11}
12
13 location/controller-class /{
14 if (! -E $ request_filename ){
15 rewrite ^/controller-class/(. *) $/controller-class/index. php? Q = $ uri & $ args;
16}
17}
18
19 location ~ \. Php $ {
20 fastcgi_pass 127.0.0.1: 9000;
21 fastcgi_index. php;
22 fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
23 fastcgi_param PHP_VALUE open_basedir = $ document_root:/tmp/:/proc /;
24 include fastcgi_params;
25}
26
27}

For more Nginx tutorials, see the following:

Deployment of Nginx + MySQL + PHP in CentOS 6.2

Build a WEB server using Nginx

Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5

Performance Tuning for Nginx in CentOS 6.3

Configure Nginx to load the ngx_pagespeed module in CentOS 6.3

Install and configure Nginx + Pcre + php-fpm in CentOS 6.4

Nginx installation and configuration instructions

Nginx log filtering using ngx_log_if does not record specific logs

Nginx details: click here
Nginx: click here

This article permanently updates the link address:

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.