Created
July 25, 2023 16:15
-
-
Save rxnlabs/62d34cc21074a8f0abb381a228627e27 to your computer and use it in GitHub Desktop.
Apache - .htaccess prevent Git repos .git/ folder from being viewable
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
# BEGIN Cornershop | |
# VCS lockdown | |
# Deny access to version control content | |
# Will not work if both Alias & Rewrite modules are disabled | |
# To verify with git content, check these two URLs: | |
# 1. /.git/HEAD | |
# 2. /.gitignore | |
<IfModule mod_alias.c> | |
# Deny access to VCS content using Alias Module | |
RedirectMatch 404 ^(.*/)?\.(git|svn|hg|bzr)+ | |
</IfModule> | |
<IfModule !mod_alias.c> | |
<IfModule mod_rewrite.c> | |
# If Alias Module is not available but Rewrite Module is, | |
# use Rewrite Module to deny access to VCS content | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^(.*/)?\.(git|svn|hg|bzr)+ - [R=404,L] | |
</IfModule> | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment