I installed a handler as such:
httpsd.conf:
-----------------
PerlModule Tofu::Tofuhandler
<Location /userfiles >
SetHandler perl-script
PerlHandler Tofu::Tofuhandler
</Location>
<Location />
AddHandler perl-script *.html
PerlHandler Tofu::Tofuhandler
</Location>
I then noticed that URI's of directories lacking a trailing '/' were not
being redirected in the browser and so relative links started to break.
As a w/o I installed a TransHandler listed below to modify the URI. It
seems like I am re-inventing the wheel here and so I assume I did something
wrong to get to this point?
Thanks for any advice.
package Tofu::Tofugruff;
#use Apache::Constants qw(:common);
use Apache::Constants qw(:response);
use strict;
sub handler {
my $r = shift;
my $f = $r->document_root.$r->uri;
my $uri = $r->uri;
if ( -d $f && $f !~/.*\/$/ ) {
# A directory that doesn't end in a '/'
$uri.='/'; # fix it
$r->err_header_out("Pragma", "no-cache");
$r->header_out("Location" => $uri );
$r->status(REDIRECT);
return DECLINED;
}
return DECLINED;
}
1;
__END__