I want to disable access to any file OR directory, whose name begins with a DOT. I came up with the following, but it disables access to files/directories beginning with DOT only if they are directly in the Document root.
<Files ~ "^\.|\/\.">
Order allow,deny
Deny from all
</Files>
With this,
http://my_server.com/.svn/entries --> Permission denied
http://my_server.com/abcd/.svn/entries --> Accessible, should be disabled
Whats the proper regex to achieve this?
You code does not work because
<Files>only applies to the basename of the requested document. That is, the part after the last slash. (source: http://httpd.apache.org/docs/current/mod/core.html#files)Apache blocks
.htaccessfiles in a default installation (better: all files starting with.ht). If you looked closely at the configuration files, you would see something like this:So to hide all files starting with a dot, you would use:
In order to make it work for directories starting with a dot, use the following (tested) code: