How do I prevent apache from serving the .git directory?

It’s not working because you have ‘svn’ instead of ‘git’ in the rule.
All you have to do is to replace the ‘svn’ with ‘git’.

<Directorymatch "^/.*/\.git/">
  Order 'deny,allow'
  Deny from all
</Directorymatch>

Leave a Comment