Skip to content

Instantly share code, notes, and snippets.

@macariojames
Forked from jaxbot/gist:5748513
Last active August 20, 2018 19:08
Show Gist options
  • Save macariojames/9b83ee4feb9d0bb21965f4169c46874b to your computer and use it in GitHub Desktop.
Save macariojames/9b83ee4feb9d0bb21965f4169c46874b to your computer and use it in GitHub Desktop.
Block nginx from serving .git directories; Block apache from serving .gif directories
# 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