On 2 Oct 2003 at 9:15, Geoffrey Young wrote:
> if you want to dynamically decide who should serve the page - mod_perl if
> some directory is found, mod_php otherwise, then you can use your own
> PerlTypeHandler or PerlFixupHandler to set $r->handler for the request based
> on your own criteria.
Many thanks - a PerlFixupHandler has done the job nicely. The fixup
handler makes the decision, turning on a custom PerlResponseHandler
if so. For the record, here's the code I arrived at:
sub handler {
my $r = shift;
my $requested_dir = $r->filename;
$requested_dir =~ s|^/home/www/html/my_site/(.*)/[^\/]*$|$1|;
return Apache::OK unless exists $permission{$requested_dir};
$r->handler('perl-script');
$r->set_handlers(PerlResponseHandler => \&restricted_response);
return Apache::OK;
}
sub restricted_response {
my $r = shift;
my $requested_dir = $r->filename;
$requested_dir =~ s|^/home/www/html/my_site/(.*)/[^\/]*$|$1|;
$r->content_type('text/plain');
print "mod_perl has taken over the $requested_dir directory...\n";
return Apache::OK;
}
1;
invoked with
<Location />
PerlFixupHandler MyApache::Permissions
</Location>
- Matthew