Reputation: 325
I can successfully block access to a file in htaccess with this:
<Files "image1.jpg">
Order Allow,Deny
Deny from all
</Files>
It works for one file, but I want to block access to thousands of files based on a pattern.
So something like this:
<Files "source_*">
Order Allow,Deny
Deny from all
</Files>
Note the * wildcard. If a file name starts with "source_" then it should deny access.
What would that look like in the correct syntax?
Upvotes: 0
Views: 214
Reputation: 286
The directive you're looking for is FilesMatch. With it, you can use Regex to specify files. Probably something like:
<FilesMatch "source_.(gif|jpe?g|png)$">
# ...
</FilesMatch>
If you want to test your Regular Expression more easily, I'd recommend Regexr
Upvotes: 1