Combine multiple FilesMatch (specific files)

Multi tool use
Multi tool use


Combine multiple FilesMatch (specific files)



How can I combine multiple FilesMatch for specific files ?



All the examples I found are for combining file extensions



In my case I only want to allow 3 files :


/img/logo.png
/sound/true.p3
/sound/false.mp3



I tested that but it's not clean :


<FilesMatch logo.png>
Allow from all
Satisfy Any
</FilesMatch>
<FilesMatch true.mp3>
Allow from all
Satisfy Any
</FilesMatch>
<FilesMatch false.mp3>
Allow from all
Satisfy Any
</FilesMatch>




1 Answer
1



You can use <filesMatch> with regex pattern to test multiple files


<filesMatch>


<filesMatch "(logo.png|true.p3|test.jpg)">
Allow from all
Satisfy Any
</filesMatch>



Documentation of the FilesMatch directive is here.


FilesMatch





Thank you, Can I add the file tree ? Like : " imglogo.png" ?
– Rocstar
Jul 2 at 9:53





Why did you add a backslash before the dot?
– Rocstar
Jul 2 at 10:21





@Rocstar FilesMatch applies only to the files that are located in the same directory as the htaccess. If your htaccess is located in /img folder then the FilesMatch will apply to all files in that folder ie <FilesMatch "file.png"> will match the the file /img/file.png .
– starkeen
Jul 2 at 15:18



<FilesMatch "file.png">


/img/file.png






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

PNl 6whzSmT
Mi3gUduJb,lYve3iTkM tGlYtY3bXx25Wr5SrdI,DI72ATSkSv3heJ57aXWwdoUWIMPY4h,pSp

Popular posts from this blog

Rothschild family

Cinema of Italy