>>>>> "darren" == darren chamberlain <[EMAIL PROTECTED]> writes:
darren> Clayton Mitchell ([EMAIL PROTECTED]) said something to this effect:
>> 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.
darren> In your handler subroutine, do something like:
darren> return DECLINED if ($r->content_type =~ /directory$/i);
darren> or
darren> return DECLINED if (-d $r->filename);
darren> HTML::Mason has this problem; Locations handled by Mason are all given to
darren> the default handler subroutine, which needs to decline directory requests.
I stole the code for Stonehenge::Pictures partially from some stuff
I saw in the Eagle book, but here's my current meme on that:
use Apache::Constants qw(:common DIR_MAGIC_TYPE);
...
sub handler {
$R = shift;
$URI = $R->uri;
...
if ($R->content_type eq DIR_MAGIC_TYPE) {
return handle_directory();
} else {
return handle_file();
}
...
sub handle_directory {
## if non-slash URL, send external redirect via mod_dir:
return DECLINED unless $URI =~ /\/$/;
...
So, I first see if content_type is DIR_MAGIC_TYPE, and then
if it doesn't also end in a slash, I decline, and the nice mod_dir
does all the external redirecting stuff.
(Stonehenge::Pictures is at
<http://www.stonehenge.com/merlyn/WebTechniques/col41.html>.)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!