Skip to content

Instantly share code, notes, and snippets.

@devluis
Forked from shrwnsan/.htaccess
Created August 8, 2013 04:32
Show Gist options
  • Save devluis/6181468 to your computer and use it in GitHub Desktop.
Save devluis/6181468 to your computer and use it in GitHub Desktop.
# Make .git files and directory web inaccessible
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*/)?\.git+ - [R=404,L]
</IfModule>
# Second line of defense (if no mod_rewrite)
RedirectMatch 404 ^(.*/)?\.git+
# Make .git files and directory web inaccessible
# Redirect it to the domain root
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "^(.*/)?\.git/" http://%{HTTP_HOST}/? [L]
</IfModule>
# Second line of defense (if no mod_rewrite)
RedirectMatch 404 ^(.*/)?\.git+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment