Forbid access to svn directories on Apache Web Server

Using Subversion to deploy and maintain updated web applications like WordPress, Joomla or even your development on a web server is very handy. One of the downsides I have found to this solution is that your web root will have hidden .svn directories all over the place (one per each directory on your application). This directories will not be hidden for the web server, so it is important to forbid browsers the access to them.

If you are using Apache, you can use the tips on this page.

If you use Apache 2.2 (I have not test it on other versions, but it should work also on 2.0 version) and have access to the configuration files, you can create the file /etc/apache2/conf.d/svn with the following content:

<Directory ~ "\.svn">
    Order allow,deny
    Deny from All
</Directory>

This will deny access to all the .svn directories on your web server. After you have create this file, do not forget to restart the web server so the changes can take effect.

Edit (26/May/2011): This can also be achieved using:

<DirectoryMatch .*\.svn/.*>
    Deny From All
</DirectoryMatch>

One thought on “Forbid access to svn directories on Apache Web Server”

  1. Great detailed information, I just bookmarked you on my google reader

    Sent from my Android phone

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? *