I read here that the “.git folder is at the root level of the web site, and is probably publicly accessible. To protect the folder and prevent unwanted clones of the repository, add the following to your top-level .htaccess file to forbid web access:”
# deny access to the top-level git repository:
RewriteEngine On
RewriteRule \.git - [F,L]
First of all, THANKS Joe Maller!
In my virtual host file i have the RewriteEngine On command with the following specs:
<VirtualHost *:80>
...
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://www.mydomain.com/ [R]
</VirtualHost>
Could i just add the git rewrite rule following the rewrite rule for ssl like so:
<VirtualHost *:80>
...
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://www.mydomain.com/ [R]
RewriteRule \.git - [F,L]
</VirtualHost>
Thanks!
That should work. It’s easy to test to make sure, though. Just try to browse to
http://www.mydomain.com/.gitand see if it works.