Skip to content

Instantly share code, notes, and snippets.

@stephenhowells
Created November 6, 2012 01:10
Show Gist options
  • Save stephenhowells/4021772 to your computer and use it in GitHub Desktop.
Save stephenhowells/4021772 to your computer and use it in GitHub Desktop.
Apache conf snippet to hide .git directories and .gitignore files.
# do not allow .git version control files to be issued
<Directorymatch "^/.*/\.git+/">
Order deny,allow
Deny from all
</Directorymatch>
<Files ~ "^\.git">
Order allow,deny
Deny from all
</Files>
@codeachange
Copy link

should be added into httpd.conf, not .htaccess

@jasco
Copy link

jasco commented Jan 22, 2015

The + matches one or more 't', which might not be what you had in mind. In any event, if you want to match the .git directory and .gitignore file you might consider a Directorymatch on "/.git/" and a Files without regex on ".gitignore"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment