You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2004/08/18 06:20:55 UTC

DO NOT REPLY [Bug 30718] New: - Allow mod_negotiation to work on URLs that map to directories

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30718>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30718

Allow mod_negotiation to work on URLs that map to directories

           Summary: Allow mod_negotiation to work on URLs that map to
                    directories
           Product: Apache httpd-1.3
           Version: 1.3.26
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Other mods
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: andrew@pimlott.net


I would like to have the URLs .../foo and .../foo/bar both work, without the
first redirecting to .../foo/.  The most promising way to do this would be to
use mod_negotiation, have a file foo.html, and a directory foo/ containing
bar.html.  This doesn't work, because mod_negotiation refuses to handle a
request for which a filesystem object exists.  This probably (?) makes sense if
the object is a file, but I doubt anyone relies on this behavior when the object
is a directory.  Anyhow, I wrote a patch to let mod_negotiation handle directories.

--- mod_negotiation.c.orig      2004-08-17 20:22:27.000000000 -0700
+++ mod_negotiation.c   2004-08-17 20:22:30.000000000 -0700
@@ -2613,7 +2613,8 @@
     int res;
     int j;
 
-    if (r->finfo.st_mode != 0 || !(ap_allow_options(r) & OPT_MULTI)) {
+    if ((r->finfo.st_mode != 0 && ! S_ISDIR(r->finfo.st_mode))
+            || !(ap_allow_options(r) & OPT_MULTI)) {
         return DECLINED;
     }

I can't think of any other simple way to get the behavior I want.  I could make
it configurable if that would help.

Apache 2 is the same, at a glance.

A gross way to achieve my goal is the following module.

#include "httpd.h"
#include "http_config.h"

module MODULE_VAR_EXPORT nodir_module;

static int handle_nodir(request_rec *r)
{
    if (S_ISDIR(r->finfo.st_mode))
        r->finfo.st_mode = 0;
    return DECLINED;
}

module MODULE_VAR_EXPORT nodir_module =
{
    STANDARD_MODULE_STUFF,
    NULL,                       /* initializer */
    NULL,                       /* dir config creator */
    NULL,                       /* dir merger --- default is to override */
    NULL,                       /* server config */
    NULL,                       /* merge server config */
    NULL,                       /* command table */
    NULL,                       /* handlers */
    NULL,                       /* filename translation */
    NULL,                       /* check_user_id */
    NULL,                       /* check auth */
    NULL,                       /* check access */
    handle_nodir,               /* type_checker */
    NULL,                       /* fixups */
    NULL,                       /* logger */
    NULL,                       /* header parser */
    NULL,                       /* child_init */
    NULL,                       /* child_exit */
    NULL                        /* post read-request */
};

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org