diff --git a/install/unix/apache2.xml b/install/unix/apache2.xml index 45b9357470bc..d5f3aa161f4a 100644 --- a/install/unix/apache2.xml +++ b/install/unix/apache2.xml @@ -265,6 +265,34 @@ LoadModule php7_module modules/libphp7.so </programlisting> </informalexample> + <para> + 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. + </para> + + <para> + 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>FilesMatch</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. + </para> + + <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