httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 39313] New: - RewriteOption Inherit adds global rules AFTER local rules. You may want the other odrer.
Date Fri, 14 Apr 2006 12:44:51 GMT
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=39313>.
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=39313

           Summary: RewriteOption Inherit adds global rules AFTER local
                    rules. You may want the other odrer.
           Product: Apache httpd-2
           Version: 2.0-HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: PatchAvailable
          Severity: enhancement
          Priority: P2
         Component: mod_rewrite
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: jerome.grandjanny@cea.fr


When you use RewriteOptions Inherit inside a VirtualHost or Directory which also has 
local rules, the global rules are added at the end of the local rules list. As a 
result, local rules are first applied, and then, global rules are applied after local 
rules. Since rules ordering in important, you may want to apply global rules first, 
and then local rules.

I propose a patch to fullfill this functionality :

- I added a new parameter "Before" to the RewriteOptions directive. You can write the 
following in a VirtualHost or Directory block in httpd.conf :

   RewriteOptions Inherit Before

which means that global rules will be applied before local rules. The default will 
still be after.

This patch modifies modules/mappers/mod_rewrite.h as follows :

# diff -c mod_rewrite.h.old mod_rewrite.h
*** mod_rewrite.h.old   Fri Feb  4 21:21:18 2005
--- mod_rewrite.h       Fri Apr 14 10:52:34 2006
***************
*** 138,143 ****
--- 138,144 ----

  #define OPTION_NONE                 1<<0
  #define OPTION_INHERIT              1<<1
+ #define OPTION_INHERIT_BEFORE       1<<2

  #define CACHEMODE_TS                1<<0
  #define CACHEMODE_TTL               1<<1


And modifies modules/mappers/mod_rewrite.c as follows (based on 2.0.55) :

# diff -c mod_rewrite.c.old mod_rewrite.c
*** mod_rewrite.c.old   Wed May 25 20:05:05 2005
--- mod_rewrite.c       Fri Apr 14 10:52:39 2006
***************
*** 212,223 ****
          a->rewritelogfp    = overrides->rewritelogfp != NULL
                               ? overrides->rewritelogfp
                               : base->rewritelogfp;
!         a->rewritemaps     = apr_array_append(p, overrides->rewritemaps,
!                                               base->rewritemaps);
!         a->rewriteconds    = apr_array_append(p, overrides->rewriteconds,
!                                               base->rewriteconds);
!         a->rewriterules    = apr_array_append(p, overrides->rewriterules,
!                                               base->rewriterules);
      }
      else {
          /*
--- 212,233 ----
          a->rewritelogfp    = overrides->rewritelogfp != NULL
                               ? overrides->rewritelogfp
                               : base->rewritelogfp;
!         if (a->options & OPTION_INHERIT_BEFORE) {
!             a->rewritemaps     = apr_array_append(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 {
!             a->rewritemaps     = apr_array_append(p, overrides->rewritemaps,
!                                                   base->rewritemaps);
!             a->rewriteconds    = apr_array_append(p, overrides->rewriteconds,
!                                                   base->rewriteconds);
!             a->rewriterules    = apr_array_append(p, overrides->rewriterules,
!                                                   base->rewriterules);
!         }
      }
      else {
          /*
***************
*** 289,298 ****
                            : base->redirect_limit;

      if (a->options & OPTION_INHERIT) {
!         a->rewriteconds = apr_array_append(p, overrides->rewriteconds,
!                                            base->rewriteconds);
!         a->rewriterules = apr_array_append(p, overrides->rewriterules,
!                                            base->rewriterules);
      }
      else {
          a->rewriteconds = overrides->rewriteconds;
--- 299,316 ----
                            : base->redirect_limit;

      if (a->options & OPTION_INHERIT) {
!         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 = apr_array_append(p, overrides->rewriteconds,
!                                                base->rewriteconds);
!             a->rewriterules = apr_array_append(p, overrides->rewriterules,
!                                                base->rewriterules);
!         }
      }
      else {
          a->rewriteconds = overrides->rewriteconds;
***************
*** 339,344 ****
--- 357,365 ----
          if (!strcasecmp(w, "inherit")) {
              options |= OPTION_INHERIT;
          }
+         else if (!strcasecmp(w, "before")) {
+             options |= OPTION_INHERIT_BEFORE;
+         }
          else if (!strncasecmp(w, "MaxRedirects=", 13)) {
              limit = atoi(&w[13]);
              if (limit <= 0) {

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message