I'm answering this myself as well, because I'm pretty sure that the issue is related to how mod_dir.c
works internally and I think it's a bug.
If a resource can't be mapped to the local file system, the function fixup_dflt()
will run, using the FallbackResource
to determine which document should be loaded instead.
However, when a resource can be mapped to the local file system and it's a directory, it will attempt to resolve the document by running fixup_dir()
; this function iterates over the list of DirectoryIndex
values until it finds the first suitable document.
In my case, the configuration has an empty list of DirectoryIndex
values, so fixup_dir()
will fail and a 404 is returned.
The following patch works for me (PR):
static int dir_fixups(request_rec *r){ if (r->finfo.filetype == APR_DIR) {- return fixup_dir(r);+ if (fixup_dir(r) != OK) {+ /* use fallback */+ return fixup_dflt(r);+ }++ return OK; } else if ((r->finfo.filetype == APR_NOFILE) && (r->handler == NULL)) { /* No handler and nothing in the filesystem - use fallback */ return fixup_dflt(r); } return DECLINED;}
It basically tries fixup_dflt()
after fixup_dir()
failed.
Update 2015-04-21
A fix has been submitted to the project, scheduled for 2.5; it may be ported to 2.4 as well.
Update 2015-05-18
The fix has been reverted because:
[...] it [at least] causes
FallBackResource
to kick in beforemod_autoindex
might have kicked in.
I'm still trying to figure out how to avoid this kind of situation.