Christian Wetzig wrote:
Hi,

i have an config handler like in
http://perl.apache.org/docs/2.0/user/config/custom.html#Creating_and_Using_Custom_Configuration_Directives

is it somehow possible to lookup the current DocumentRoot from within a
directive handler like the following

  sub MyParameter {
      my ($self, $parms, @args) = @_;
      # somehow get DocumentRoot (not ServerRoot)
  }

I haven't tested this but you might want to try:

  use Apache2::Directive ();

  my $tree = Apache2::Directive::conftree();

  my $documentroot = $tree->lookup('DocumentRoot');

from:

http://perl.apache.org/docs/2.0/api/Apache2/Directive.html#Synopsis

or if you need a specific virtual host's document root then:

  my $vhost = $tree->lookup('VirtualHost', 'myhost:myport');
  my $docroot = $vhost->{'DocumentRoot'};

> $parms->server->server_hostname gives me the current VirtualHost, but > i see no
> method for looking up DocumentRoot.

I don't see a $s->document_root method in Apache2::ServerRec which is where I would expect to see it... but try the above examples and see if those help.

HTH,

- Fred

Reply via email to