Did you mean to use nested location blocks? I tried it but it didn't work. Here is the relevant part of my configuration file:
# define web root
root /var/www/html/public;
index index.php index.html;
location /index.php {
location ~* (?:.*/index.php)(.*) {
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
}
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}