From 7459ae80a8d068b5fa5a1399be262fef00d5bf67 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Fri, 21 Feb 2014 19:47:26 +0000 Subject: [PATCH] Merge r1570288 from trunk: *) mod_rewrite: Add RewriteOptions InheritDown, InheritDownBefore, and IgnoreInherit to allow RewriteRules to be pushed from parent scopes to child scopes without explicitly configuring each child scope. PR56153. Submitted By: Edward Lu Committed By: covener Submitted by: covener Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1570684 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ STATUS | 7 ------- docs/manual/mod/mod_rewrite.xml | 28 ++++++++++++++++++++++++++++ modules/mappers/mod_rewrite.c | 28 ++++++++++++++++++++++++---- 4 files changed, 57 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 02438fac02..1065b612fc 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ Changes with Apache 2.4.8 + *) mod_rewrite: Add RewriteOptions InheritDown, InheritDownBefore, + and IgnoreInherit to allow RewriteRules to be pushed from parent scopes + to child scopes without explicitly configuring each child scope. + PR56153. [Edward Lu ] + *) prefork: Fix long delays when doing a graceful restart. PR 54852 [Jim Jagielski, Arkadiusz Miskiewicz ] diff --git a/STATUS b/STATUS index 4cd7c62bb8..ff7a682b5c 100644 --- a/STATUS +++ b/STATUS @@ -98,13 +98,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_rewrite: Add RewriteOptions InheritDown, InheritDownBefore, - and IgnoreInherit to allow RewriteRules to be pushed from parent scopes - to child scopes without explicitly configuring each child scope. - PR56153. - trunk patch: http://svn.apache.org/r1570288 - 2.4.x patch: trunk works - +1 covener, humbedooh, jim PATCHES PROPOSED TO BACKPORT FROM TRUNK: diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index 1816da86fd..50417a7313 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -173,6 +173,34 @@ later Available in Apache HTTP Server 2.3.10 and later.

+
InheritDown
+
+ +

If this option is enabled, all child configurations will inherit + the configuration of the current configuration. It is equivalent to + specifying RewriteOptions Inherit in all child + configurations. See the Inherit option for more details + on how the parent-child relationships are handled. Available in Apache + HTTP Server 2.4.8 and later.

+
+ +
InheritDownBefore
+
+ +

Like InheritDown above, but the rules from the current + scope are applied before rules specified in any child's + scope. Available in Apache HTTP Server 2.4.8 and later.

+
+ +
IgnoreInherit
+
+ +

This option forces the current and child configurations to ignore + all rules that would be inherited from a parent specifying + InheritDown or InheritDownBefore. Available + in Apache HTTP Server 2.4.8 and later.

+
+
AllowNoSlash

By default, mod_rewrite will ignore URLs that map to a diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index e1903e5cba..7646407bf3 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -192,6 +192,9 @@ static const char* really_last_key = "rewrite_really_last"; #define OPTION_NOSLASH 1<<3 #define OPTION_ANYURI 1<<4 #define OPTION_MERGEBASE 1<<5 +#define OPTION_INHERIT_DOWN 1<<6 +#define OPTION_INHERIT_DOWN_BEFORE 1<<7 +#define OPTION_IGNORE_INHERIT 1<<8 #ifndef RAND_MAX #define RAND_MAX 32767 @@ -2765,7 +2768,9 @@ static void *config_server_merge(apr_pool_t *p, void *basev, void *overridesv) a->server = overrides->server; - if (a->options & OPTION_INHERIT) { + if (a->options & OPTION_INHERIT || + (base->options & OPTION_INHERIT_DOWN && + !(a->options & OPTION_IGNORE_INHERIT))) { /* * local directives override * and anything else is inherited @@ -2777,7 +2782,9 @@ static void *config_server_merge(apr_pool_t *p, void *basev, void *overridesv) a->rewriterules = apr_array_append(p, overrides->rewriterules, base->rewriterules); } - else if (a->options & OPTION_INHERIT_BEFORE) { + else if (a->options & OPTION_INHERIT_BEFORE || + (base->options & OPTION_INHERIT_DOWN_BEFORE && + !(a->options & OPTION_IGNORE_INHERIT))) { /* * local directives override * and anything else is inherited (preserving order) @@ -2854,13 +2861,17 @@ static void *config_perdir_merge(apr_pool_t *p, void *basev, void *overridesv) a->directory = overrides->directory; - if (a->options & OPTION_INHERIT) { + if (a->options & OPTION_INHERIT || + (base->options & OPTION_INHERIT_DOWN && + !(a->options & OPTION_IGNORE_INHERIT))) { a->rewriteconds = apr_array_append(p, overrides->rewriteconds, base->rewriteconds); a->rewriterules = apr_array_append(p, overrides->rewriterules, base->rewriterules); } - else if (a->options & OPTION_INHERIT_BEFORE) { + else if (a->options & OPTION_INHERIT_BEFORE || + (base->options & OPTION_INHERIT_DOWN_BEFORE && + !(a->options & OPTION_IGNORE_INHERIT))) { a->rewriteconds = apr_array_append(p, base->rewriteconds, overrides->rewriteconds); a->rewriterules = apr_array_append(p, base->rewriterules, @@ -2912,6 +2923,15 @@ static const char *cmd_rewriteoptions(cmd_parms *cmd, else if (!strcasecmp(w, "inheritbefore")) { options |= OPTION_INHERIT_BEFORE; } + else if (!strcasecmp(w, "inheritdown")) { + options |= OPTION_INHERIT_DOWN; + } + else if(!strcasecmp(w, "inheritdownbefore")) { + options |= OPTION_INHERIT_DOWN_BEFORE; + } + else if (!strcasecmp(w, "ignoreinherit")) { + options |= OPTION_IGNORE_INHERIT; + } else if (!strcasecmp(w, "allownoslash")) { options |= OPTION_NOSLASH; } -- 2.40.0