]> granicus.if.org Git - apache/commitdiff
PR 39313: allow the user to configure which rules come first when RewriteRules
authorEric Covener <covener@apache.org>
Sat, 4 Dec 2010 22:33:46 +0000 (22:33 +0000)
committerEric Covener <covener@apache.org>
Sat, 4 Dec 2010 22:33:46 +0000 (22:33 +0000)
are merged with RewriteOptions Inherit.

Submitted By: Jérôme Grandjanny <jerome.grandjanny cea.fr>
Reviewed By: covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1042255 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_rewrite.xml
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 88e017b58aa5eee70eeef0f705c359b4034e3a86..48fc211f2605c19140d4b7030bdba7c33065f37a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 
 Changes with Apache 2.3.10
 
+  *) mod_rewrite: Add 'RewriteOptions InheritBefore' to put the base 
+     rules/conditions before the overridden rules/conditions.  PR 39313.
+     [Jérôme Grandjanny <jerome.grandjanny cea.fr>]
+
   *) mod_autoindex: add IndexIgnoreReset to reset the list of IndexIgnored
      filenames in higher precedence configuration sections.  PR 24243.
      [Eric Covener]
index 6afbf5571d0cebbe35fe1005f8b72b226155f682..061beb53a071eb4c0456833d3ebebdd9eeacae62 100644 (file)
@@ -140,7 +140,7 @@ later</compatibility>
       only be one of the following:</p>
 
       <dl>
-      <dt><code>inherit</code></dt>
+      <dt><code>Inherit</code></dt>
       <dd>
       
       <p>This forces the current configuration to inherit the
@@ -163,7 +163,16 @@ later</compatibility>
       <strong>after</strong> rules specified in the child scope.
       </note>
       </dd>
+
+      <dt><code>InheritBefore</code></dt>
+      <dd>
+      <p> Like <code>Inherit</code> above, but the rules from the parent scope
+      are applied <strong>after</strong> rules specified in the child scope.  
+      Available in Apache HTTP Server 2.3.10 and later.</p>
+      </dd>
+      
       </dl>
+
 </usage>
 
 </directivesynopsis>
index 2f7a7dc9d42cc10a3c5656ead9c800e28357fece..431e5fa8d5b339f31e068ef5e42798ba27ef71fe 100644 (file)
@@ -187,6 +187,7 @@ static const char* really_last_key = "rewrite_really_last";
 
 #define OPTION_NONE                 1<<0
 #define OPTION_INHERIT              1<<1
+#define OPTION_INHERIT_BEFORE       1<<2
 
 #ifndef RAND_MAX
 #define RAND_MAX 32767
@@ -2745,6 +2746,18 @@ 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) {
+        /*
+         *  local directives override
+         *  and anything else is inherited (preserving order)
+         */
+        a->rewritemaps     = apr_hash_overlay(p, base->rewritemaps,
+                                              overrides->rewritemaps);
+        a->rewriteconds    = apr_array_append(p, base->rewriteconds,
+                                              overrides->rewriteconds);
+        a->rewriterules    = apr_array_append(p, base->rewriterules, 
+                                              overrides->rewriterules);
+    }
     else {
         /*
          *  local directives override
@@ -2810,6 +2823,12 @@ static void *config_perdir_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) {
+        a->rewriteconds    = apr_array_append(p, base->rewriteconds,
+                                              overrides->rewriteconds);
+        a->rewriterules    = apr_array_append(p, base->rewriterules,
+                                              overrides->rewriterules);
+    }
     else {
         a->rewriteconds = overrides->rewriteconds;
         a->rewriterules = overrides->rewriterules;
@@ -2853,6 +2872,9 @@ static const char *cmd_rewriteoptions(cmd_parms *cmd,
         if (!strcasecmp(w, "inherit")) {
             options |= OPTION_INHERIT;
         }
+        else if (!strcasecmp(w, "inheritbefore")) {
+            options |= OPTION_INHERIT_BEFORE;
+        }
         else if (!strncasecmp(w, "MaxRedirects=", 13)) {
             ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
                          "RewriteOptions: MaxRedirects option has been "