I recently had a need to have mod_dir in Apache 1.3 work even when I was using a Perl handler. It turns out that mod_dir does its thing during the response phase. So I created a quick Perl module to do what I want. Here's the description:
This simple module is designed to be a partial replacement for the
standard Apache mod_dir module. One of the things that module does is
to redirect browsers to a directory URL ending in a slash when they
request the directory without the slash. Since mod_dir seems do its
thing during the Apache response phase, if you use a Perl handler, it
won't run. This can be problematic if the Perl handler doesn't likewise
take the directory redirecting into account.
A good example is HTML::Mason. If you've disabled Mason's decline_dirs
parameter (MasonDeclineDirs 0 in httpd.conf), and there's a dhandler in
the directory /foo, then for a request for /foo, /foo/dhandler will
respond. This can wreak havoc if you use relative URLs in the dhandler.
What really should happen is that a request for /foo will be redirected
to /foo/ before Mason ever sees it.
This is the problem that this module is designed to address. Thanks to
mod_perl's ability to stack handlers, you can just make sure that
Apache::Dir handles requests before Mason does. Configuration would
then look something like this:
<Location /foo>
PerlSetVar MasonDeclineDirs 0
PerlModule Apache::Dir
PerlModule HTML::Mason::ApacheHandler
SetHandler perl-script
PerlHandler Apache::Dir HTML::Mason::ApacheHandler
</Location>You can download it to try it out here:
http://theory.kineticode.com/code/Apache-Dir-0.01.tar.gz
There are at least two issues that I need to address before releasing it on CPAN, though:
1. Doug has the Apache::Dir namespace reserved. Did he have some working code for this already?
http://search.cpan.org/~dougm/
2. Maybe this isn't necessary in Apache 2. I really don't know, so I'm asking you guys. Can mod_dir be stacked/chained to execute before a Perl handler in Apache 2/mod_perl 2?
Thanks!
David
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
