I'm trying to secure the .git and svn directories from anyone being able to access them because they contain sensitive meta information.
I've tried using the following rule but I'm receiving an internal server error and I'm not sure why:
<Directorymatch "^/(.*/)*\.(git|svn)/">
Require all denied
</Directorymatch>
Any ideas?
As per Apache 2.4 documentation, DirectoryMatch
directive is not allowed in .htaccess
You can use mod_rewrite
directives to do the same in your site root .htaccess:
RewriteEngine On
RewriteRule \.(git|svn)(/.*)?$ - [F,NC]