Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache FilesMatch

Tags:

apache

With Apache, I can target files by extension like this:

<FilesMatch "\.(gif|jpg|png|js|css)$">

Can you also target specific files by their entire filename. For example "bg.jpg":

<FilesMatch "bg.jpg">

Would that work?

Thanks, Ben

like image 425
Globalz Avatar asked Jun 19 '26 10:06

Globalz


2 Answers

Yes, that will work but you need to escape the dot (\.) if you want to use FilesMatch. You could also simply use Files.

like image 129
joschi Avatar answered Jun 23 '26 03:06

joschi


It's a regular expression, which means you should anchor it with a caret "^" in front and a dollar sign "$" at the end. Plus escape the dot, as joschi said.

like image 33
jcomeau_ictx Avatar answered Jun 23 '26 04:06

jcomeau_ictx