I've just encountered an issue whereby our FallbackResource is applied correctly, except where the URL requested ends in .php.
For example:
It seems that it's because the docker-php.conf configuration file sets the PHP Handler for any file which matches .php, and therefore the FallbackResource (handler) is not applied.
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
https://github.com/docker-library/php/blob/master/8.4/bookworm/apache/Dockerfile#L97-L99
This has been raised (and rejected) in the Apache Bugzilla:
https://bz.apache.org/bugzilla/show_bug.cgi?id=52403#c7
There seems to be a few possible solutions:
- Use
AddType instead of AddHandler or SetHandler. I'm not sure if this is suggestion on the bz issue is from the Apache team, or is an observeration. I'm not sure whether this is a viable option
- Wrap the
SetHandler call in a conditional
- Switch to
mod_rewrite (not generally recommended now that FallbackResource exists)
Re 2, the change would be something like this:
<FilesMatch \.php$>
<If "-f %{REQUEST_FILENAME}">
SetHandler application/x-httpd-php
</If>
</FilesMatch>
(Suggestion found here: https://stackoverflow.com/questions/50439963/apache-fallbackresource-configuration)
This would likely have a performance impact, but I would imagine no worse than using mod_rewrite.
I've tested the conditional SetHandler locally and it works as expected.
I've just encountered an issue whereby our
FallbackResourceis applied correctly, except where the URL requested ends in.php.For example:
It seems that it's because the docker-php.conf configuration file sets the PHP Handler for any file which matches
.php, and therefore the FallbackResource (handler) is not applied.https://github.com/docker-library/php/blob/master/8.4/bookworm/apache/Dockerfile#L97-L99
This has been raised (and rejected) in the Apache Bugzilla:
https://bz.apache.org/bugzilla/show_bug.cgi?id=52403#c7
There seems to be a few possible solutions:
AddTypeinstead ofAddHandlerorSetHandler. I'm not sure if this is suggestion on the bz issue is from the Apache team, or is an observeration. I'm not sure whether this is a viable optionSetHandlercall in a conditionalmod_rewrite(not generally recommended now thatFallbackResourceexists)Re 2, the change would be something like this:
(Suggestion found here: https://stackoverflow.com/questions/50439963/apache-fallbackresource-configuration)
This would likely have a performance impact, but I would imagine no worse than using
mod_rewrite.I've tested the conditional SetHandler locally and it works as expected.