Nginx support for codeigniter pathinfo mode URL Rewrite configuration example _nginx

Source: Internet
Author: User
Tags codeigniter

Development environment

CodeIgniter 2.14
PHP 5.4.18
Nginx 1.4.2

CodeIgniter Configuration

The config.php file that opens Codeignite is modified as follows:

$config [' uri_protocol '] = "path_info";

Nginx Configuration

Open the Nginx profile nginx.conf file and modify it as follows:

# I am using the virtual host configuration
server {
  listen  ;
  server_name dev.example.com;

  Rewrite_log on;

  root/www/web/htdocs/dev.example.com;
  Index index.php index.html index.htm;

  Location/{
    index index.php index.html index.htm;
  }

  Location ~ \.php ($|/) {
   fastcgi_pass 127.0.0.1:9000;
   Fastcgi_index index.php;
   Fastcgi_split_path_info ^ (. +\.php) (. *) $;
   Fastcgi_param path_info $fastcgi _path_info;
   Fastcgi_param script_filename $document _root$fastcgi_script_name;
   Include  fastcgi_params;
  }

  if (!-e $request _filename) {
   rewrite ^/(. *) $/index.php/$1 last;
   break;

  Location ~/\.ht {
    deny all;
  }
}

You can now access it in PathInfo mode, such as:

Http://dev.example.com/app/welcome/test

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.