I need to dynamically change DocumentRoot for some subdomains pointing to the same local path.
This rule works (almost) as expected, but has an issue with links to subfolders without trailing slash:
RewriteCond %{HTTP_HOST} ^foo\.domain\.com$
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule .* /foo%{REQUEST_URI} [QSA,L]
That is
http://foo.domain.com/bar/ works, while
http://foo.domain.com/bar is redirected to a wrong local path (/foo/foo/bar instead of /foo/bar)