Restricting Access to Your Git Directory

July 22, 2010
logo@2x

One task you need to be sure to do when implementing git on a website > is to make sure the .git directory isn’t available to the Internet.

This can be done by placing an .htaccess file in the .git directory itself, but a better cleaner way is to place the following line in your main .htaccess file.

RedirectMatch 403 /.git.*$

::

supporting = loving

For 29.4719 years I've been creating ad-free technical tutorials and essays here. 3,033 pieces and counting.

It's a one-person effort that's also my livelihood. If it makes your day easier or more pleasant in any way, please consider supporting the work with a monthly or one-time donation.

It helps me make more content, and is deeply appreciated as well. 🫶🏼