Bug 56067 - FallbackResource doesn't work if directory exists
Summary: FallbackResource doesn't work if directory exists
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_dir (show other bugs)
Version: 2.4.7
Hardware: All All
: P2 normal with 3 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-27 06:45 UTC by Jack
Modified: 2019-01-06 13:05 UTC (History)
3 users (show)



Attachments
If a directory exists but no indexes can be resolved, the fallback resource should be attempted first before giving up. (456 bytes, patch)
2015-04-21 05:47 UTC, Jack
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jack 2014-01-27 06:45:03 UTC
Observe the following directory structure:

 index.html
 test/
   bla.txt

And the following configuration:

 DirectoryIndex disabled
 DirectorySlash Off
 FallbackResource /index.html

This all works fine (index.html is shown) if the document can't be mapped to the file system; however, when `/test/` is requested, it will show a 404 page.

This is also disussed in the following question: http://serverfault.com/questions/568952/use-fallbackresource-even-if-directory-exists

I've written a patch for this:

 static int dir_fixups(request_rec *r)
 {
     if (r->finfo.filetype == APR_DIR) {
         /* serve up a directory */
 -        return fixup_dir(r);
 +        if (fixup_dir(r) == DECLINED) {
 +            return fixup_dflt(r);
 +        }
     }
     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;
 }
Comment 1 Jack 2014-01-27 07:06:48 UTC
I've added a PR for this: https://github.com/apache/httpd/pull/5
Comment 2 Jack 2015-04-21 05:47:45 UTC
Created attachment 32669 [details]
If a directory exists but no indexes can be resolved, the fallback resource should be attempted first before giving up.
Comment 3 Eric Covener 2015-04-21 12:25:35 UTC
(In reply to Jack from comment #2)
> Created attachment 32669 [details]
> If a directory exists but no indexes can be resolved, the fallback resource
> should be attempted first before giving up.

committed with tweaks and a small paranoia addition in http://svn.apache.org/viewvc?view=revision&revision=1675103.  Proposed for backport.
Comment 4 Eric Covener 2015-05-18 16:30:24 UTC
This had to be reverted because it broke mod_autoindex and potentially something more complicated
Comment 5 Jack 2015-05-19 21:15:24 UTC
(In reply to Eric Covener from comment #4)
> This had to be reverted because it broke mod_autoindex and potentially
> something more complicated

Is there a different direction we can take with this issue?