* md <[EMAIL PROTECTED]> [2002-06-12 13:15]:
> --- Per Einar Ellefsen <[EMAIL PROTECTED]> wrote:
> > Can't you just drop the <Location> and use
> > <Files *.phtml>
> > SetHandler ....
> > </Files>
> > or something like that? Seems like it would avoid
> > some overhead for you.
>
> True...but the files don't actually exist. The
> path/filename is used to map to a template.
You definitely want to do this in the translation phase; that's what
it's there for.
> > However, I'm not sure if I understand what you mean
> > with
> > $uri =~ m!.*/[^\.]+$!) {
>
> This may not be the best regex..but what I was trying to do was to
> match something like "/directory/subdirectory" which would normally be
> redirected back to "/directory/subdirectory/index.html" (or whatever
> is set as DirectoryIndex files). I want to check for a
> "/directory/subdirectory/index.phtml" file.
If you use a translation handler, you can just return DECLINED for
everything you aren't specifically handling, and let mod_dir do it's
thing, instead of emulating it.
I think what you want is something like this:
package Foo; # or whatever
use strict;
use Apache::Constants qw(OK DECLINED);
sub handler {
my $r = shift;
return DECLINED unless $r->uri =~ /\.phtml$/;
# Figure out which template to use here
my $template_name = get_template_name($r);
$r->filename($template_name);
return OK;
}
1;OK;
(darren)
--
Reisner's Rule of Conceptual Inertia:
If you think big enough, you'll never have to do it.