Can't get Codeigniter URLs working on Nginx

Shubham asked:

After successfully setting up nginx on my windows, another problem where I am stuck. Though, everything works as usual. I am able to access pages and PHP works fine but problem comes when I try to use Codeigniter type urls, by which, I mean,


Even if I insert one slash after “index.php” an error No input file specified is thrown which I think means the FastCGI server is not able to catch the right file. Here is my config file,

server {
    server_name localhost;
    listen 443; 
    root /wamp/www/;

    ssl on;
    ssl_certificate /wamp/www/server.crt;
    ssl_certificate_key /wamp/www/server.key;

    location / {        
        index index.php index.html index.htm;

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

    # pass the PHP scripts to FastCGI server listening on
    location ~ \.php$ {
            fastcgi_intercept_errors on;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;

Nothing in error logs and access logs are filled with 404 requests. If I remove the try_files line, I get a nginx 404 page.

My answer:

Looks like you need to use fastcgi_split_path_info.

An example:

fastcgi_split_path_info       ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO       $fastcgi_path_info;

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.