I use Mercurial (hg) and git to manage a few of my personal projects. Some of those projects are exposed to the web (my site, for example). I don’t want the .hg/ and .git/ directories to be available to people via apache, there is no reason (especially since i’m not hosting those repos publicly). I wanted a sitewide solution to deny access to those directories, and I figured blocking .svn would be worthwhile while I was at it.
I run debian on my VPS, so these instructions will be targeted towards how debian (and its derivatives, like ubuntu) structure the apache configuration. It would be trivial to adapt my solution to another distro’s configuration.
I created a file called /etc/apache2/conf.d/deny-scm.conf
The file’s contents:
## Deny access to various scm directories ## by Ryan (ryan@paluminum.net) 1-15-2009 # Deny access to .hg/ directories <directory ~ "\.hg"> Order allow,deny deny from all </directory> # .git <directory ~ "\.git"> Order allow,deny deny from all </directory> # .svn <directory ~ "\.svn"> Order allow,deny deny from all </directory>
0 Response to “Deny SCM directories with apache”