1

I've installed Codeigniter on Nginx with this configuration :

server {
listen       80;
server_name  myserver;

root /usr/share/nginx/html;
index index.php index.html index.htm;
error_log /var/log/nginx/localhost.error_log debug;
 location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
            expires max;
            log_not_found off;
    }
location / {
    try_files $uri $uri/ /index.php?/$request_uri;
        location = /index.php {

            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
            include        fastcgi_params;
        }
}

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

i also changed configuration on ceodeignigter in this way :

...
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
...

this is my default controller :

<?php

class Index extends CI_Controller {
    public function __construct(){
            parent::__construct();
    }
    public function index(){
        $this->load->view('index');
    }
}

i can access my default Controller, what i've defined on router.php file but i can't access other Controllers yet . any help would be appreciate .

OnlyMAJ
  • 167
  • 3
  • 11

1 Answers1

0

I use

location / {
  try_files $uri $uri/ /index.php;
}

and it works. You can also add

try_files /index.php$request_uri;

at the end. There is no ? after index.php in CI.

Sharad D
  • 101
  • 2