RE: Make .git directory web inaccessible
I currently have the following:
<Directorymatch "^/.*/\.git/">
Order deny,allow
Deny from all
</Directorymatch>
Instead of a 500 error page, is there a way to modify the .htaccess code above to make it just go to the main domain? Thanks in advance.
UPDATE
I also have the following mod_rewrite which got me closer:
RewriteEngine On
RewriteRule "^(.*/)?\.git/" http://%{HTTP_HOST}/? [L]
However, it only triggers if its "domain.com/.git" and not any child .git folders. E.g.
domain.com/folder/.git
domain.com/folder/sub-folder/.git
Thanks in advance for the help.