On Fri 28 Mar 2008, Valerio wrote:
> I set both document_root and filename: can I set just only the
> filename or the document-root or I have to set both them?

filename is just enough. You need to set docroot only if you have CGI scripts 
or similar that use it. You can also set only docroot and return DECLINED. 
The default trans handler then does the rest.

You may also want to cache your DB lookups at least for the duration of the 
request. There are subrequests (when a directory index is created or mod_cgi 
computes PATH_TRANSLATED or similar). Each one of those would repeat the DB 
lookup otherwise.

sub handler {
  my $r=shift;

  my $vpath;
  if( $r->prev ) {               # handle subrequests
    $vpath=$r->prev->notes->{vpath};
  } elsif( $r->main ) {          # handle internal redirects (ErrorDocument)
    $vpath=$r->main->notes->{vpath};
  } else {
    $vpath=db_lookup(...);
    $r->notes->{vpath}=$vpath;
  }

  $r->filename($vpath.$r->uri);
  return Apache2::Const::OK;
}

Torsten

Reply via email to