Last active
December 17, 2015 23:49
-
-
Save shrwnsan/5692615 to your computer and use it in GitHub Desktop.
Make .git files and directory web inaccessible. There's two solutions below for your preference. One redirects to a 404, and the other to domain root. I use a 404. (Based on my Stack Overflow post @ http://j.mp/17fb164)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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