On Wed, 29 Oct 2008 15:29:18 -0400
Michael wrote:

> So what's going on here. Shouldn't the 2 requests (/foo
> and /foo/index.pl) be treated exactly the same?

/foo is much different than /foo/index.pl because /foo is handled by
mod_dir (http://httpd.apache.org/docs/2.0/mod/mod_dir.html).

First, the client must submit the request with a trailing slash, as in
'/foo/'. This is done by returning a 301 redirect (mod_dir). Then, the
redirected (canonical) request comes in and mod_dir starts looking
for your directory index file. Each potential index file is probed via
an Apache sub-request. Your cleanup handler will get called for each
of these sub-requests, and then again on the initial request. You may
find everything is "logical" if you put this at the top of your cleanup

return Apache2::Const::OK unless $r->is_initial_req;