-
-
Save macariojames/9b83ee4feb9d0bb21965f4169c46874b to your computer and use it in GitHub Desktop.
Block nginx from serving .git directories; Block apache from serving .gif directories
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
# For nginx -- goes in the /sites-available/domainnamehere.com file | |
location ~ /\.git { | |
return 404; | |
#deny all; | |
} | |
# or, all . directories/files in general (including .htaccess, etc) | |
# i like to use 'deny all' for all . files ~mj | |
location ~ /\. { | |
deny all; | |
} | |
# -------- START APACHE STUFF BELOW; IGNORE IF YOU USED NGINX STUFF ABOVE ~mj ----- | |
# For apache -- goes in the .htaccess file | |
# it 404 for all files/directories starting with .git so .gitignore as well | |
# Great since doesn't let the visitor know .git is being used ~mj | |
RedirectMatch 404 /\.git | |
# For apache -- if you don't want the approach above use: | |
<Directorymatch "^/.*/\.git/"> | |
Order deny,allow | |
Deny from all | |
</Directorymatch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment