]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
add support for rewrite rules in proxy containers
authorAndré Malo <nd@apache.org>
Thu, 26 Aug 2004 21:53:24 +0000 (21:53 +0000)
committerAndré Malo <nd@apache.org>
Thu, 26 Aug 2004 21:53:24 +0000 (21:53 +0000)
PR: 27985
Reviewed by: Jeff Trawick, Bill Stoddard

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

CHANGES
STATUS
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 200ac997a797bdda8b09379696b790b516804a8e..95093a91066092db22d4b073a6ea2f8ea32e131e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.51
 
+  *) mod_rewrite now officially supports RewriteRules in <Proxy> sections.
+     PR 27985.  [André Malo]
+
   *) mod_disk_cache: Implement binary format for on-disk header files.
      [Brian Akins <bakins web.turner.com>, Justin Erenkrantz]
 
diff --git a/STATUS b/STATUS
index 7a120f6a871933d6c0223b0940a2fbb9114cac77..0ee3440c3543d3df896da03eaabc07d61144b615 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2004/08/26 21:18:37 $]
+Last modified at [$Date: 2004/08/26 21:53:23 $]
 
 Release:
 
@@ -178,10 +178,6 @@ PATCHES TO BACKPORT FROM 2.1
          http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/loggers/mod_log_config.c?r1=1.118&r2=1.119
        +1: trawick, nd, jerenkrantz
 
-    *) (re-)add support for RewriteRules in <Proxy> containers. PR 27985
-         modules/mappers/mod_rewrite.c: r1.254
-       +1: nd, trawick, stoddard
-
     *) mod_include: remove "recursive-include" check, it's no longer
        necessary and forbids legal actions.
           modules/filters/mod_include.c: r1.296
index b2ef7871372fe354f4d72a151ad36ea651a8be4e..71cd0b61ac3e12980a4e796045b22d146006df8a 100644 (file)
@@ -1395,6 +1395,7 @@ static int hook_fixup(request_rec *r)
     int rulestatus;
     int n;
     char *ofilename;
+    int is_proxyreq;
 
     dconf = (rewrite_perdir_conf *)ap_get_module_config(r->per_dir_config,
                                                         &rewrite_module);
@@ -1415,16 +1416,24 @@ static int hook_fixup(request_rec *r)
         return DECLINED;
     }
 
+    /*
+     * Proxy request?
+     */
+       is_proxyreq = (   r->proxyreq && r->filename
+                      && !strncmp(r->filename, "proxy:", 6));
+
     /*
      *  .htaccess file is called before really entering the directory, i.e.:
      *  URL: http://localhost/foo  and .htaccess is located in foo directory
      *  Ignore such attempts, since they may lead to undefined behaviour.
      */
-    l = strlen(dconf->directory) - 1;
-    if (r->filename && strlen(r->filename) == l &&
-        (dconf->directory)[l] == '/' &&
-        !strncmp(r->filename, dconf->directory, l)) {
-        return DECLINED;
+    if (is_proxyreq) {
+        l = strlen(dconf->directory) - 1;
+        if (r->filename && strlen(r->filename) == l &&
+            (dconf->directory)[l] == '/' &&
+            !strncmp(r->filename, dconf->directory, l)) {
+            return DECLINED;
+        }
     }
 
     /*
@@ -1920,6 +1929,7 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
     rewritecond_entry *c;
     int i;
     int rc;
+    int is_proxyreq = 0;
 
     /*
      *  Initialisation
@@ -1945,7 +1955,13 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
      *  threatment in the logfile.
      */
     if (perdir) {
-        if (   strlen(uri) >= strlen(perdir)
+        /*
+            * Proxy request?
+         */
+           is_proxyreq = (   r->proxyreq && r->filename
+                          && !strncmp(r->filename, "proxy:", 6));
+
+        if (   !is_proxyreq && strlen(uri) >= strlen(perdir)
             && strncmp(uri, perdir, strlen(perdir)) == 0) {
             rewritelog(r, 3, "[per-dir %s] strip per-dir prefix: %s -> %s",
                        perdir, uri, uri+strlen(perdir));
@@ -2145,7 +2161,8 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
      *   location, i.e. if it's not an absolute URL (!) path nor
      *   a fully qualified URL scheme.
      */
-    if (perdir && *r->filename != '/' && !is_absolute_uri(r->filename)) {
+    if (   perdir && !is_proxyreq && *r->filename != '/'
+        && !is_absolute_uri(r->filename)) {
         rewritelog(r, 3, "[per-dir %s] add per-dir prefix: %s -> %s%s",
                    perdir, r->filename, perdir, r->filename);
         r->filename = apr_pstrcat(r->pool, perdir, r->filename, NULL);