I want to work simple url like http://host/test.php
, note there are no
trailing /
at the end.
I start from standard config from nginx site + serverfault:
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^((?U).+\.php)(.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
}
end http://host/test.php/
works, but http://host/test.php
without trailing /
do not work.
I try to change to such config:
location ~ \.php$ {
fastcgi_split_path_info ^/(.+\.php)(.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
}
and I got 404, and get from php-fpm
Primary script unknown
So have you idea how to make http://host/test.php
works without trailing /
?
I tried many variants, but failed to understand what is wrong. I used nginx 1.8.1
Update
1) This problem only appears if I set chroot
in /etc/php-fpm.d/www.conf
2) I find out using strace
that for url with test.php/
php-fpm got
SCRIPT_NAME/test.php\v\n
and with url test.php
I got SCRIPT_NAME/test.php\v\t
. So first one end with '\n' and second one end with '\t' can not get why.
Update 2 Looks like a bug, I try 1.9.13 and the same config, not working with 1.8.1, works fine.