PDA

View Full Version : How to disable .svn directories


derdewey
09-22-2006, 03:37 AM
I'm trying to get a better workflow going for rolling out a rails app from a svn repo and I wanted to know how the .htaccess in $RAILS_ROOT/public/ should be edited to disable access to the nitty gritties in .svn folders.

I tried following the rails wiki:

<DirectoryMatch "^/.*/\.svn/">
Order deny,allow
Deny from all
</DirectoryMatch>

but apache threw up saying "DirectoryMatch not allowed here". Any ideas peeps?

Matt
09-22-2006, 01:39 PM
You have a couple of options:

1) Use mod_rewrite to match the .svn directory pattern and send a 403 error code (forbidden), e.g.:
RewriteEngine On
RewriteCond %{REQUEST_URI} /\.svn/
RewriteRule . - [F]

2) After running svn update, find all .svn directories and remove the world execute bit: find . -type d -name .svn -print -exec chmod 750 "{}" \; That will prohibit the Web server from directly accessing the file. If you try accessing the directory from within a CGI script such as a Rails application, then it'll go through without a hitch because suexec changes uids from apache to yours.