Apache's AcceptPathInfo
This behaviour is controlled with the AcceptPathInfo
Directive in both Apache 2.2 and 2.4:
This directive controls whether requests that contain trailing
pathname information that follows an actual filename (or non-existent
file in an existing directory) will be accepted or rejected. The
trailing pathname information can be made available to scripts in the
PATH_INFO
environment variable.
For example, assume the location /test/
points to a directory that
contains only the single file here.html
. Then requests for
/test/here.html/more
and /test/nothere.html/more
both collect /more
as
PATH_INFO
.
By default
core handler rejects PATH_INFO
for normal files
other handlers like mod_cgi, mod_isapi or mod_php generally accept PATH_INFO
.
If you want explicitly disable this for all handlers, use:
AcceptPathInfo Off
PHP-FPM
The AcceptPathInfo
doesn't seem to work with PHP-FPM e.g. if there's a proxy handler like this:
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
<Proxy "fcgi://localhost/">
</Proxy>
In that case you could e.g. forbid access to all URLs containing .php/
.