At 18:41 12.06.2002, md wrote: >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.
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. However, I'm not sure if I understand what you mean with $uri =~ m!.*/[^\.]+$!) { >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. Hmm, but if you don't have a template, then you have nothing to serve, right? >httpd.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? -- Per Einar Ellefsen [EMAIL PROTECTED]