Block .git and .svn folders on Apache

Posted on .

Add the following to <VirtualHost>,

# Deny access to git/svn files
<Directorymatch "^/(.*/)*\.(git|svn)/">
Order deny,allow
Deny from all
</Directorymatch>

According to this answer, a .htaccess file with this will do the same,

RewriteEngine On
RewriteRule "^(.*/)?\.(git|svn)/" - [F,L]

Leave a Reply

You may leave the Name and Email fields blank to post anonymously.