Hide Git Directories With Mod Rewrite

Last modified: 
Thursday, April 9th, 2015

Overview

Htaccess rule to prevent access to hidden files and directories from prying eyes. This is especially useful for .git repositories which may contain sensitive information or expose code vulnerabilities. Requires mod_rewrite.


  RewriteEngine on
  # Block access to .hidden files and directories.
  RewriteRule "(^|/)\." - [F]

Source

This is taken from the Drupal default .htaccess file.


The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.