-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
I've just encountered an issue whereby our FallbackResource is applied correctly, except where the URL requested ends in .php.
For example:
- http://localhost/example.html => Uses FallbackResource
- http://localhost/example.php => Does not use FallbackResource and results in a 404
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>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
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 option - Wrap the
SetHandlercall in a conditional - Switch to
mod_rewrite(not generally recommended now thatFallbackResourceexists)
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.