Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up a DAV server with Apache 2.2 and would like, if at all possible, to be able to redirect a user to their own folder without having per-user URLs, if at all possible.

So I point a user to https://dav.example.org/, I have authentication enabled (AuthType Digest, AuthDigestProvider file) so the user logs in, and then content is served from /home/%{REMOTE_USER}/dav.

Or that's the theory anyway. The problem is I can't get it to work. The basic rule (at least to start with - I know this won't necessarily redirect everything, but if I can get the root folder to work and at least get an index of files, I can tweak the reg-ex later):

RewriteEngine On
RewriteCond %{LA-U:REMOTE_USER} (.*)
RewriteRule ^/        /home/%1/dav/

The problem is that the lookahead doesn't seem to work - it always returns an empty string (I'm running with RewriteLogLevel 5, and get "RewriteCond: input='' pattern='(.*)' => matched" in the log). I know I'm logged in with a username as I can see the user in the appropriate field in access_log.

I've also tried moving this into .htaccess, but it didn't seem to play there (the rewrite engine didn't seem to even start); similarly, it didn't play under a config in the main config file (again, it looked like it failed to process any of the rules).

I had some success with it under in that the remote-user was successfully mapped, but then it got stuck in a recursive loop (error log tells me "Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary.", and then I read in the manual that wasn't really supported anyway[1], so I'm rejecting that path.

It looks like what I'm doing should be straightforward, but I'm failing to see what I'm missing.

Trying to keep config/log snippets brief here to keep question tidy - can add snippets on request.

[1] The manual for mod_rewrite in 2.2 says "Although rewrite rules are syntactically permitted in and sections, this should never be necessary and is unsupported."

EDIT ... this is the virtual site config (I've got a number of virtual sites, so I'm assuming that the root httpd.conf isn't needed)

<VirtualHost *:443>
    SSLEngine on
    SSLProtocol -ALL +TLSv1
    SSLCertificateFile <edited out>
    SSLCertificateKeyFile <edited out>
    SSLCACertificateFile <edited out>
    SSLCertificateChainFile <edited out>
    SSLHonorCipherOrder On

    ServerAdmin admin@localhost
    DocumentRoot /var/www/dav.example.org
    ServerName dav.example.org
    ErrorLog /var/log/apache2/dav.example.org.errlog
    CustomLog /var/log/apache2/dav.example.org.log combined
    RewriteLog /var/log/apache2/dav.example.org.rewritelog
    RewriteLogLevel 5
    LogLevel debug

    <Location />
            Options Indexes FollowSymLinks
            Order allow,deny
            Allow from all
            Dav On

            AuthName DAV
            AuthType Digest
            AuthDigestProvider file
            AuthUserFile /tmp/dig

            <LimitExcept OPTIONS>
                    # Testing only - running single-user
                    Require user cej

    RewriteEngine On
    RewriteCond %{LA-U:REMOTE_USER} (.*)
    RewriteRule ^/        /home/%1/dav/
share|improve this question
Please provide httpd.conf – Simon Hayter Apr 11 '13 at 22:32
@bybe -- vhost config added – Chris J Apr 11 '13 at 22:38
Does the Apache service have permission to read within the user groups home folders? – Simon Hayter Apr 12 '13 at 8:12
Yes. Originally this was configured with a hard-coded path (i.e., DocumentRoot was pointing at /home/<whatever>/dav), and that worked swimmingly. I'm now just trying to make the physical location for this dynamic on the username. I guess an alternative approach would be so that someone pointed to https://dav.example.org/<user>/ and there's a RewriteCond to make sure the <user> portion of the URL matches %{REMOTE_USER} and thus redirects accordingly, but I still have the problem that %{REMOTE_USER} and %{LA-U:REMOTE_USER} don't seem to get expanded (so again the condition can't be checked). – Chris J Apr 12 '13 at 13:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.