[doc-en] master: apache2.xml Add notes about FallbackResource (#4580)
| From: | Andrew Lyons via GitHub | Date: | Fri, 03 Jul 2026 14:36:56 +0000 |
| Subject: | [doc-en] master: apache2.xml Add notes about FallbackResource (#4580) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23437@lists.php.net to get a copy of this message | ||
Author: Andrew Lyons (andrewnicols)
Committer: GitHub (web-flow)
Pusher: jordikroon
Date: 2026-07-03T16:36:53+02:00
Commit: https://github.com/php/doc-en/commit/a38e360ae1ce4169b331013958c519d17f19114e
Raw diff: https://github.com/php/doc-en/commit/a38e360ae1ce4169b331013958c519d17f19114e.diff
apache2.xml Add notes about FallbackResource (#4580)
* apache2.xml Add notes about FallbackResource
Co-authored-by: Jordi Kroon <jordikroon@php.net>
Changed paths:
M install/unix/apache2.xml
Diff:
diff --git a/install/unix/apache2.xml b/install/unix/apache2.xml
index 45b9357470bc..23024391b65e 100644
--- a/install/unix/apache2.xml
+++ b/install/unix/apache2.xml
@@ -265,6 +265,34 @@ LoadModule php7_module modules/libphp7.so
</programlisting>
</informalexample>
+ <simpara>
+ To allow use of a PHP file as the default handler if no other handler is found,
+ for example when using a routing engine, the <literal>FallbackResource</literal>
directive may be used.
+ This is available in Apache 2.4.4 and later.
+ </simpara>
+
+ <simpara>
+ Because the <literal>SetHandler</literal> directive is applied whether the file
exists or not, and the
+ <literal>FallbackResource</literal> is only applied if a handler has not already
been set,
+ you may need to use the <literal>If</literal> directive to ensure that the handler
is only
+ applied if the file exists.
+ This allows the <literal>FallbackResource</literal> to handle paths which end in
<literal>.php</literal>
+ but do not exist, which may be useful for error handling and routing.
+ </simpara>
+
+ <informalexample>
+ <programlisting role="apache-conf">
+<![CDATA[
+<FilesMatch "\.php$">
+ <If "-f %{REQUEST_FILENAME}">
+ SetHandler application/x-httpd-php
+ </If>
+</FilesMatch>
+FallbackResource /index.php
+]]>
+ </programlisting>
+ </informalexample>
+
<para>
<literal>mod_rewrite</literal> may be used to allow any arbitrary
<literal>.php</literal> file to be displayed
as syntax-highlighted source code, without having to rename or copy it