Mobile app version of vmapp.org
Login or Join
Hamaas447

: Mapping different users to folders with mod_rewrite 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

@Hamaas447

Posted in: #ModRewrite

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 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
SSLCipherSuite RC4-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DES-CBC3-SHA

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
</LimitExcept>
</Location>

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

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Hamaas447

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme