Tim Esselens wrote:
> Hi,
> 
> I'm having problems with the following construct:
> 
> -[httpd.conf]------------------------------------
> <FilesMatch \.phtml$>
>         PerlInitHandler Dispatcher
> </FilesMatch>
> 
> -[Dispatcher.pm]---------------------------------
> sub handler() {
>         # do some stuff to get $module
>         $r->push_handlers(PerlResponseHandler => $module);
>         return Apache2::Const::OK;
> }
> 
> If I request http://localhost/index.phtml everything works perfectly
> If I request http://localhost/ which in turn uses the DirectoryIndex
> directive to get to index.phtml, the file is served from disk w/o using the
> handler (as if it were a normal html file).
> 
> Thing is, If I add the following to my httpd.conf (say $module was Test::X)
> everything works out fine (both URIs are processed by Test::X->handler())
> 
> <FilesMatch \.phtml$>
>         PerlResponseHandler Test::X
> </FilesMatch>
> 
> Is PerlInitHandler a hook too early for adding PerlResponseHandlers?

Not too early, but the mapping / => index.phtml is done by mod_autoindex at
a later phase, so when your InitHandler _could_ kick in, the request still
has $r->filename point to the directory, FIlesMatch \.phtml$ _not_ matching.

You should try something like:

<Directory /top/level/path/where/your/files/are>
  PerlInitHandler Dispatcher
</Directory>

sub handler() {
        my $r = shift;
        return DECLINED unless $r->filename =~ /\.phtml$/;
        [...]
}

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to