I'm trying to create a webdav website for a number of clients to upload/download files. However I'm not going each client to determine another clients' data. Each client uses SSL client certificates to authenticate, so I must chroot them to their own directory tree.

For instance:

I figured which i can use mod_rewrite with this but my rules appear to transmit me into an infinite redirection loop. Any ideas?

Alias /webdav /somewebroot/webdav
<Directory /somewebroot/webdav>
    RewriteEngine On
    RewriteBase /webdav

    RewriteCond %{SSL:SSL_CLIENT_S_DN_CN} ADMIN #The admin does not get chrooted
    RewriteRule .* - [L]

    RewriteCond %{REQUEST_URI} !^%{SSL:SSL_CLIENT_S_DN_CN}/(.*)
    RewriteRule ^(.*) %{SSL:SSL_CLIENT_S_DN_CN}/$1 [L]
</Directory>

The treatment for this really is quite simple when you determine that "RewriteCond" doesn't support server variables within the PATTERN. So you've to have it in to the pattern using a backreference. Also "RewriteCond" doesn't make use of the "RewriteBase" directive so you might also need to consider that into consideration too.

Alias /webdav /somewebroot/webdav
<Directory /somewebroot/webdav>
    RewriteEngine On
    RewriteBase /webdav

    RewriteCond %{SSL:SSL_CLIENT_S_DN_CN} ADMIN #The admin does not get chrooted
    RewriteRule .* - [L]

    RewriteCond %{SSL:SSL_CLIENT_S_DN_CN}::%{REQUEST_URI} !^(.*)::/webdav/\1/(.*)
    RewriteRule ^(.*) %{SSL:SSL_CLIENT_S_DN_CN}/$1 [L]
</Directory>