I have an application where I want the effective DocumentRoot to change
based on dynamic properties in the request.
In particular, we are creating a number of domain aliases, pointing to the
same IP address, so that each user can view their own version of the web
site. e.g.
joe.dev.mysite.com would have doc root /home/joe/www
dave.dev.mysite.com would have doc root /home/dave/www
etc. I could do this with a set of virtual servers, but then I have to
change the httpd.conf and restart the server every time a user is
added, which is undesirable.
Here's what I wanted to work:
sub trans_handler
{
my ($r) = @_;
my ($user) = ($r->header_in('Host') =~ /^[^\.]+/);
$r->document_root("/home/$user/www");
return DECLINED;
}
PerlTransHandler trans_handler
but I got
[error] Usage: Apache::document_root(r) at handler.pl line 41
so document_root ain't writable.
Any other suggestions? I'm loathe to recreate the entire default Apache
directory handler in my trans_handler (looking for index.html, etc.)
Jon