From: André Malo Date: Sat, 3 Jul 2004 16:43:39 +0000 (+0000) Subject: make trailing-slash-behaviour configurable X-Git-Tag: pre_ajp_proxy~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=acbb11eddfac5acedc8ac85242bfb958902831f6;p=apache make trailing-slash-behaviour configurable git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104154 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 9226be9ee2..5e427e5695 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) mod_dir: the trailing-slash behaviour is now configurable using the + DirectorySlash directive. [André Malo] + *) mod_proxy: multiple bugfixes, principally support cookies in ProxyPassReverse, and don't canonicalise URL passed to backend. Documentation correspondingly updated. [Nick Kew ] diff --git a/modules/mappers/mod_dir.c b/modules/mappers/mod_dir.c index 8bd5b9e60b..c6e7f0d506 100644 --- a/modules/mappers/mod_dir.c +++ b/modules/mappers/mod_dir.c @@ -30,8 +30,15 @@ module AP_MODULE_DECLARE_DATA dir_module; +typedef enum { + SLASH_OFF = 0, + SLASH_ON, + SLASH_UNSET +} slash_cfg; + typedef struct dir_config_struct { apr_array_header_t *index_names; + slash_cfg do_slash; } dir_config_rec; #define DIR_CMD_PERMS OR_INDEXES @@ -47,10 +54,20 @@ static const char *add_index(cmd_parms *cmd, void *dummy, const char *arg) return NULL; } +static const char *configure_slash(cmd_parms *cmd, void *d_, int arg) +{ + dir_config_rec *d = d_; + + d->do_slash = arg ? SLASH_ON : SLASH_OFF; + return NULL; +} + static const command_rec dir_cmds[] = { AP_INIT_ITERATE("DirectoryIndex", add_index, NULL, DIR_CMD_PERMS, "a list of file names"), + AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS, + "On or Off"), {NULL} }; @@ -59,6 +76,7 @@ static void *create_dir_config(apr_pool_t *p, char *dummy) dir_config_rec *new = apr_pcalloc(p, sizeof(dir_config_rec)); new->index_names = NULL; + new->do_slash = SLASH_UNSET; return (void *) new; } @@ -69,6 +87,8 @@ static void *merge_dir_configs(apr_pool_t *p, void *basev, void *addv) dir_config_rec *add = (dir_config_rec *)addv; new->index_names = add->index_names ? add->index_names : base->index_names; + new->do_slash = + (add->do_slash == SLASH_UNSET) ? base->do_slash : add->do_slash; return new; } @@ -95,11 +115,18 @@ static int fixup_dir(request_rec *r) return DECLINED; } + d = (dir_config_rec *)ap_get_module_config(r->per_dir_config, + &dir_module); + /* Redirect requests that are not '/' terminated */ if (r->uri[0] == '\0' || r->uri[strlen(r->uri) - 1] != '/') { char *ifile; + if (!d->do_slash) { + return DECLINED; + } + /* Only redirect non-get requests if we have no note to warn * that this browser cannot handle redirs on non-GET requests * (such as Microsoft's WebFolders). @@ -127,9 +154,6 @@ static int fixup_dir(request_rec *r) return DECLINED; } - d = (dir_config_rec *)ap_get_module_config(r->per_dir_config, - &dir_module); - if (d->index_names) { names_ptr = (char **)d->index_names->elts; num_names = d->index_names->nelts;