If need PATH_INFO
If need PATH_INFO (URI like /index.php/search), you need to use $document_root$fastcgi_script_name, because fastcgi_split_path_info cannot use $request_filename
If using root directive
$document_root$fastcgi_script_name is equal to $request_filename.
If using alias directive
$document_root$fastcgi_script_name will return the wrong path, because $fastcgi_script_name is path of the URI, not the path relate to $document_root.
Example
location /api/ {
index index.php index.html index.htm;
alias /app/www/;
location ~* "\.php$" {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
Request /api/testing.php:
$document_root$fastcgi_script_name == /app/www//api/testing.php
$request_filename == /app/www/testing.php
Request /api/:
$document_root$fastcgi_script_name == /app/www//api/index.php
$request_filename == /app/www/index.php
And if you use $request_filename, you should set index using index directive, fastcgi_index will not work.