Reputation: 49533
Nginx returns a 404 when I query for an URL with a "path info" appended after the script name, e.g. http://example.com/index.php/hello.
Here is my config:
server {
listen 80;
root @PROJECT_ROOT@/;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:@PHP_FPM_SOCK@;
include fastcgi_params;
fastcgi_read_timeout 300s;
}
}
I don't get why \.php$
doesn't match that URL, and I've tried searching for similar problems but can't find anything useful.
Upvotes: 0
Views: 2099
Reputation: 10407
This works for me:
location ~ \.php {
# Split the path appropriately
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Work around annoying nginx "feature" (https://trac.nginx.org/nginx/ticket/321)
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
# Make sure the script exists.
try_files $fastcgi_script_name =404;
# Configure everything else. This part may be different for you.
fastcgi_pass localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Upvotes: 1
Reputation: 2415
Use
location ~ ^.+.php {
fastcgi_split_path_info ^(.+?.php)(/.*)$;
to match a .php in the uri split the parameters
Upvotes: 2