For poorly configured Apache servers you can have to do something like this to deny access to the .htaccess file:

<Files .htaccess>
order allow,deny
deny from all
</Files>

Now is it possible to use a wildcard in the filename? I would like to deny access to all system files (.* - any file that it's filename starts with a dot). I would like to know if the following would work for what I want:

<Files .*>
order allow,deny
deny from all
</Files>
link|improve this question
feedback

1 Answer

up vote 3 down vote accepted

What you need there is FilesMatch:

<FilesMatch "^\.">
    [config]
</FilesMatch>

(The pattern is a regexp, rather than a glob, though).

More Info here

link|improve this answer
Would <FilesMatch "^\."> be better? – Activist Jul 21 '11 at 17:51
Actually, yes. My regex \..* doesn't anchor at the start of the line, which would be pretty messy for most web sites :) Fixed. – SmallClanger Jul 21 '11 at 18:09
Yeah it's what I tought ;) – Activist Jul 21 '11 at 18:12
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.