Skip to content

apache2.xml Add notes about FallbackResource#4580

Merged
jordikroon merged 2 commits into
php:masterfrom
andrewnicols:fallbackResourceFileMatch
Jul 3, 2026
Merged

apache2.xml Add notes about FallbackResource#4580
jordikroon merged 2 commits into
php:masterfrom
andrewnicols:fallbackResourceFileMatch

Conversation

@andrewnicols

@andrewnicols andrewnicols commented Apr 3, 2025

Copy link
Copy Markdown
Contributor

I recently encountered an issue when configuring a FallbackResource for Apache.

We are in the process of migrating legacy paths to use a routing engine and as part of the migration we are providing a shim. As a result we have users hitting paths such as /example.php which are now expected to be handled by the Routing system.

We discovered that our Apache2 test images were not hitting the Routing system for these paths and, after digging, that it's because the SetHandler and AddHandler directives are set based on the path location rather than the file. That is, if the location https://example.com/example.php is requested then the <FilesMatch> directive is always applied based on the \.php$ regex match. As a result, the FallbackResource directive is not applied (beceause a Handler has already been applied).

This has previously been rejected as a bug in Apache2 as it is the expected behaviour.

I have:

Given that the FallbackResource is the recommended way to use a routing system such as Symfony it is probably worth documenting:

  • the use of the FallbackResource directive; and
  • the need to use an If -f directive when setting the handler to only apply it when the requested file actually exists.

@andrewnicols

Copy link
Copy Markdown
Contributor Author

Is there anything I can do to help progress this issue?

Thanks

@andrewnicols

Copy link
Copy Markdown
Contributor Author

Hi folks,

Just wondering if there's anything I can do to help progress this patch?

@lacatoire

Copy link
Copy Markdown
Member

LGTM - Documents a real gotcha that affects many PHP developers using modern routing. Clear explanation with working solution.

@andrewnicols

Copy link
Copy Markdown
Contributor Author

Hi folks,

I'm still looking for a merge on this. This has now been noted on the Apache docs too:

@mmalferov I think you're the main contributor in this space. Are you able to review this or point me in the right direction?

@andrewnicols andrewnicols force-pushed the fallbackResourceFileMatch branch from 3c011a3 to d6bc948 Compare April 30, 2026 07:38
Comment thread install/unix/apache2.xml Outdated
Comment thread install/unix/apache2.xml Outdated
andrewnicols and others added 2 commits July 3, 2026 16:33
@jordikroon jordikroon force-pushed the fallbackResourceFileMatch branch from dba8cc1 to fbf33c9 Compare July 3, 2026 14:33
@jordikroon

Copy link
Copy Markdown
Member

Hi @andrewnicols. I am very sorry this has been on the shelf for so long. I have rebased your branch and fixed some minor style nits on your behalf. The changed look good to me. Thank you for your efforts.

@jordikroon jordikroon merged commit a38e360 into php:master Jul 3, 2026
2 checks passed
lacatoire added a commit to php/doc-fr that referenced this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants