Skip to content

Incompatibility with FallbackResource and SetHandler #1576

Description

@andrewnicols

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:

  1. 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
  2. Wrap the SetHandler call in a conditional
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions