How to exclude a directory from FilesMatch
I have the following .htaccess directive:
<FilesMatch ".(htm|html|php)$">
php_value auto_prepend_file "/home/abc/public_html/_prepend.php"
php_value auto_append_file "/home/abc/public_html/_append.php"
</FilesMatch>
I need to exclude a very specific directory '/ home / abc / public_html / exclude /' from auto_prepend and auto_append.
Is it possible?
source to share
... htaccess files - What are they / How to use them explains how .htaccess
files work
A file containing one or more configuration directives is placed in a specific document directory, and the directives are applied to that directory and all of its subdirectories.
This means that you can create a .htaccess file in /home/abc/public_html/
, and another in /home/abc/public_html/exclude/
, containing the same, different, or even conflicting directives.
Looking at PHP -auto_prepend_file
you can see that
The special value
none
disables automatic addition.
The same applies to auto_append_file
.
Combining the two means you can have an existing .htaccess
# /home/abc/public_html/.htaccess
<FilesMatch ".(htm|html|php)$">
php_value auto_prepend_file "/home/abc/public_html/_prepend.php"
php_value auto_append_file "/home/abc/public_html/_append.php"
</FilesMatch>
and second .htaccess in subdirectory exclude
# /home/abc/public_html/exclude/.htaccess
<FilesMatch ".(htm|html|php)$">
php_value auto_prepend_file none
php_value auto_append_file none
</FilesMatch>
source to share