Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apache2.xml Add notes about FallbackResource #4580

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions install/unix/apache2.xml
Original file line number Diff line number Diff line change
@@ -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