]> granicus.if.org Git - apache/commitdiff
add support for rewrite rules in proxy containers
authorAndré Malo <nd@apache.org>
Mon, 29 Mar 2004 21:34:19 +0000 (21:34 +0000)
committerAndré Malo <nd@apache.org>
Mon, 29 Mar 2004 21:34:19 +0000 (21:34 +0000)
PR: 27985

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

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index b61e8dd902069e5876dd83b5dc85bedcd30a5a2c..a902bd875dcb7315e5163ca21146eeb11311c437 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) mod_rewrite now officially supports RewriteRules in <Proxy> sections.
+     PR 27985.  [André Malo]
+
   *) mod_cgid: Don't allow Scriptsock to be specified inside VirtualHost;
      Don't place script socket inside default server root instead of
      actual server root.  PR 27886.  [Jeff Trawick]
index 15976223c4a711ca4b77360d8107b64670f1cdea..b7bd6b9bde72d98a3943f759555784fc296a6f50 100644 (file)
@@ -3590,12 +3590,19 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
     int i, rc;
     char *newuri = NULL;
     request_rec *r = ctx->r;
+    int is_proxyreq = 0;
 
     ctx->uri = r->filename;
 
     if (ctx->perdir) {
         apr_size_t dirlen = strlen(ctx->perdir);
 
+        /*
+         * Proxy request?
+         */
+        is_proxyreq = (   r->proxyreq && r->filename
+                       && !strncmp(r->filename, "proxy:", 6));
+
         /* Since we want to match against the (so called) full URL, we have
          * to re-add the PATH_INFO postfix
          */
@@ -3608,7 +3615,7 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
         /* Additionally we strip the physical path from the url to match
          * it independent from the underlaying filesystem.
          */
-        if (strlen(ctx->uri) >= dirlen &&
+        if (!is_proxyreq && strlen(ctx->uri) >= dirlen &&
             !strncmp(ctx->uri, ctx->perdir, dirlen)) {
 
             rewritelog((r, 3, ctx->perdir, "strip per-dir prefix: %s -> %s",
@@ -3721,7 +3728,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
      * (1) it's an absolute URL path and
      * (2) it's a full qualified URL
      */
-    if (ctx->perdir && *r->filename != '/' && !is_absolute_uri(r->filename)) {
+    if (   ctx->perdir && !is_proxyreq && *r->filename != '/'
+        && !is_absolute_uri(r->filename)) {
         rewritelog((r, 3, ctx->perdir, "add per-dir prefix: %s -> %s%s",
                     r->filename, ctx->perdir, r->filename));
 
@@ -4338,6 +4346,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);
@@ -4353,16 +4362,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;
+        }
     }
 
     /*