From: André Malo Date: Thu, 26 Aug 2004 21:53:24 +0000 (+0000) Subject: add support for rewrite rules in proxy containers X-Git-Tag: STRIKER_2_0_51_RC1^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67f131a1836a0eb6a4f2b6c5a1ff161047a2fda3;p=thirdparty%2Fapache%2Fhttpd.git add support for rewrite rules in proxy containers 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 --- diff --git a/CHANGES b/CHANGES index 200ac997a79..95093a91066 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.51 + *) mod_rewrite now officially supports RewriteRules in sections. + PR 27985. [André Malo] + *) mod_disk_cache: Implement binary format for on-disk header files. [Brian Akins , Justin Erenkrantz] diff --git a/STATUS b/STATUS index 7a120f6a871..0ee3440c354 100644 --- 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 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 diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index b2ef7871372..71cd0b61ac3 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -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);