I'd like to configure httpd.conf
to deny files that match either of the following:
- A directory that starts with
.
or_
- A file that starts with
.
or_
, but does not match__\w+__\.\w+
For example:
/_private/anything -> deny (rule 1)
/_private/__init__.py -> deny (rule 1)
/_private/_private.txt -> deny (rule 1+2)
/public/_private.txt -> deny (rule 2)
/public/__private.txt -> deny (rule 2)
/public/__public__.txt -> allow
I've been working with <Directory ~ "...">
and <Files ~ "...">
as well as RewriteRule
, but haven't been able to get it working just right.
Suggestions much appreciated!
Thanks!
Update: in response to CK:
<Directory "/var/www/html">
Order allow,deny
Allow from all
</Directory>
Update 2: Does anyone know why this directive is matching and denying a url like /_test.php
, when it is clearly not a "directory" ? (I removed ALL <Files>
sections except the .htaccess one.)
<Directory ~ "/[._]">
Order allow,deny
Deny from all
</Directory>