I'm replacing an exisiting PHP site with mod_perl and
Template-Toolkit.
I normally set up mod_perl to use a location like
this:
<Location /something>
and set the handler to my mod_perl module.
However, I need to map to "/" since I'm replacing a
system where there are existing PHP files like
www.someserver.com/index.php or
www.someserver.com/about.php.
I decided to do use
<Location />
to map to my main mod_perl script.
The first thing it does is to check if the uri ends
with a .phtml extension (or www.someserver.com or
www.someserver.com/...same with subdirectories). If
there is, I continue processing, otherwise I decline
it and let Apache handle it.
If I have a .phtml (or a directory index) I check if I
have a template. If I have a template TT takes over,
if not I return DECLINED and let Apache take over.
http.conf
---------
<Location />
PerlSetVar websrc_root /usr/local/templates
SetHandler perl-script
PerlHandler Test::MyModule
</Location>
Beginning of MyModule.pm
-------------------------
# Get the uri
my($uri, $uri2);
$uri = $uri2 = $r->uri;
$uri2 =~ s[^/][]; # remove the leading '/'
# We only want to see .phtml files, or urls that end
with '/'
# or where the stuff past the last '/' doesn't contain
any '.'s.
# We'll check the later two case for a template and
then
# decline it if no template is found.
unless ($uri =~ /\.phtml$/ or
$uri =~ m!/$! or
$uri =~ m!.*/[^\.]+$!) {
return DECLINED;
}
Is this the best way to do this?
--
Thanks
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com