-*- coding: utf-8 -*-
Changes with Apache 2.5.0
+
+ *) mod_dir: Add DirectoryCheckHandler to allow a 2.2-like behavior, skipping
+ execution when a handler is already set. PR53929. [Eric Covener]
+
*) mod_rewrite: Protect against looping with the [N] flag by enforcing a
default limit of 10000 iterations, and allowing each rule to change its
limit. [Eric Covener]
</highlight>
</usage>
</directivesynopsis>
+<directivesynopsis>
+<name>DirectoryCheckHandler</name>
+<description>Toggle how this module responds when another handler is configured</description>
+<syntax>DirectoryCheckHandler On|Off</syntax>
+<default>DirectorySlash Off</default>
+<contextlist><context>server config</context><context>virtual host</context>
+<context>directory</context><context>.htaccess</context></contextlist>
+<override>Indexes</override>
+<compatibility>Available in 2.4.8 and later. Releases prior to 2.4 implicitly
+act as if "DirectorySlash Off" was specified.</compatibility>
+<usage>
+ <p>The <directive>DirectoryCheckHandler</directive> directive determines
+ whether <module>mod_dir</module> should check for directory indexes or
+ add trailing slashes when some other handler has been configured for
+ the current URL. Handlers can be set by directives such as
+ <directive module="core">SetHandler</directive> or by other modules,
+ such as <module>mod_rewrite</module> during per-directory substitutions.
+ </p>
+
+ <p> In releases prior to 2.4, this module did not take any action if any
+ other handler was configured for a URL. This allows directory indexes to
+ be served even when a <directive>SetHandler</directive> directive is
+ specified for an entire directory, but it can also result in some conflicts
+ with modules such as <directive>mod_rewrite</directive>.</p>
+</usage>
+</directivesynopsis>
</modulesynopsis>
typedef struct dir_config_struct {
apr_array_header_t *index_names;
moddir_cfg do_slash;
+ moddir_cfg checkhandler;
int redirect_index;
const char *dflt;
} dir_config_rec;
d->do_slash = arg ? MODDIR_ON : MODDIR_OFF;
return NULL;
}
+static const char *configure_checkhandler(cmd_parms *cmd, void *d_, int arg)
+{
+ dir_config_rec *d = d_;
+
+ d->checkhandler = arg ? MODDIR_ON : MODDIR_OFF;
+ return NULL;
+}
static const char *configure_redirect(cmd_parms *cmd, void *d_, const char *arg1)
{
dir_config_rec *d = d_;
"a list of file names"),
AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS,
"On or Off"),
+ AP_INIT_FLAG("DirectoryCheckHandler", configure_checkhandler, NULL, DIR_CMD_PERMS,
+ "On or Off"),
AP_INIT_TAKE1("DirectoryIndexRedirect", configure_redirect,
NULL, DIR_CMD_PERMS, "On, Off, or a 3xx status code."),
new->index_names = NULL;
new->do_slash = MODDIR_UNSET;
+ new->checkhandler = MODDIR_UNSET;
new->redirect_index = REDIRECT_UNSET;
return (void *) new;
}
new->index_names = add->index_names ? add->index_names : base->index_names;
new->do_slash =
(add->do_slash == MODDIR_UNSET) ? base->do_slash : add->do_slash;
+ new->checkhandler =
+ (add->checkhandler == MODDIR_UNSET) ? base->checkhandler : add->checkhandler;
new->redirect_index=
(add->redirect_index == REDIRECT_UNSET) ? base->redirect_index : add->redirect_index;
new->dflt = add->dflt ? add->dflt : base->dflt;
return HTTP_MOVED_PERMANENTLY;
}
+ if (d->checkhandler == MODDIR_ON && strcmp(r->handler, DIR_MAGIC_TYPE)) {
+ return DECLINED;
+ }
+
if (d->index_names) {
names_ptr = (char **)d->index_names->elts;
num_names = d->index_names->nelts;