HOME BLOG

How to prevent web application from revealing git repository details

Posted on: August 21st, 2021 by Olu No Comments

Hi folks,

In this post I will discuss a security tip. If your web application uses Git for version control, then there would usually be a .git folder in the project’s root folder. Here’s a quick way to prevent users from accessing details under your .git folder from a web browser.

Implement a 404 redirect for any request starting with /.git.

If you use Apache web server and your project users a .htaccess file, you can do this by adding a simple rule to your .htaccess file as follows:

RedirectMatch 404 /\.git

That’s all for now. Happy software development.

Leave a Reply