Reputation: 262
The root of my website includes FilesMatch in the .htaccess to make sure I do not rewrite those files.
<FilesMatch "\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|woff|svg|ttf|pdf|gz)$">
RewriteEngine Off
</FilesMatch>
There is one subdirectory I like to protect by sending all files through a php file to check permission. The htaccess in there is
RewriteEngine On
RewriteRule ^(.*)$ /protect.php [L]
But this excludes all files matched by filesmatch in the root. When I try to override (same filesmatch sentence but with RewriteEngine On the files are still ignored.
Can I override FilesMatch in subdirs?
Upvotes: 1
Views: 974
Reputation: 74048
You can do so, but you must wrap the complete ruleset in it
<FilesMatch "\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|woff|svg|ttf|pdf|gz)$">
RewriteEngine On
RewriteRule ^(.*)$ /protect.php [L]
</FilesMatch>
Upvotes: 1