Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Overriding FilesMatch in subdirectory
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

There is one subdirectory I like to protect by sending all files through a php file to check permission. The htaccess in there is

PHP Code:
RewriteEngine On
^(.*)$ /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?

You can do so, but you must wrap the complete ruleset in it

PHP Code:
<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
^(.*)$ /protect.php [L]
All resources on the forum clean. Sometimes Virus total give false positives. Also developers may insert backdoors, if you find it, contact me.


Users browsing this thread: 1 Guest(s)