How to avoid index.php in Zend Framework route using Nginx rewrite
- by Adam Benayoun
I am trying to get rid of index.php from the default Zend Framework route. I think it should be corrected at the server level and not on the application. (Correct me if I am wrong, but I think doing it on the server side is more efficient).
I run Nginx 0.7.1 and php-fpm 5.3.3
This is my nginx configuration
server {
    listen *:80;
        server_name domain;
        root   /path/to/http;
        index index.php;
        client_max_body_size 30m;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location /min {
                try_files $uri $uri/ /min/index.php?q=;
        }
        location /blog {
                try_files $uri $uri/ /blog/index.php;
        }
        location /apc {
                try_files $uri $uri/ /apc.php$args;
        }
        location ~ \.php {
                include /usr/local/etc/nginx/conf.d/params/fastcgi_params_local;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_script_name;
                fastcgi_param SERVER_NAME $http_host;
                fastcgi_pass 127.0.0.1:9000;
        }
        location ~* ^.+\.(ht|svn)$ {
                deny  all;
        }
        # Static files location
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
            expires max;
        }
}
Basically www.domain.com/index.php/path/to/url and www.domain.com/path/to/url serves the same content.
I'd like to fix this using nginx rewrite.
Any help will be appreciated.