fielding 97/04/15 23:07:46
Modified: src CHANGES mod_rewrite.h mod_rewrite.c Log: Fixes HTTP redirects from within .htaccess files. The RewriteBase was not replaced correctly due to a nasty for-loop bug. Now RewriteEngine on RewriteBase /~coar RewriteRule ^FOO$ BAR [R] will also work for you, Ken ;-) and fixes some typos in the comments. Submitted by: Ralf S. Engelschall <[EMAIL PROTECTED]> Reviewed by: Ken Coar, Roy Fielding Revision Changes Path 1.234 +4 -0 apache/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache/src/CHANGES,v retrieving revision 1.233 retrieving revision 1.234 diff -C3 -r1.233 -r1.234 *** CHANGES 1997/04/15 20:22:58 1.233 --- CHANGES 1997/04/16 06:07:43 1.234 *************** *** 1,5 **** --- 1,9 ---- Changes with Apache 1.2 + *) Updated mod_rewrite to 3.0.4: Fixes HTTP redirects from within + .htaccess files because the RewriteBase was not replaced correctly. + [Ralf S. Engelschall] + *) Back out the HAVE_SHMGET change for Linux because it's too late in the beta cycle to deal cleanly with compilation problems on the myriad of linux systems out there. Linux users should see 1.21 +1 -1 apache/src/mod_rewrite.h Index: mod_rewrite.h =================================================================== RCS file: /export/home/cvs/apache/src/mod_rewrite.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C3 -r1.20 -r1.21 *** mod_rewrite.h 1997/04/12 04:19:49 1.20 --- mod_rewrite.h 1997/04/16 06:07:43 1.21 *************** *** 64,70 **** ** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___| ** |_____| ** ! ** URL Rewriting Module, Version 3.0.3 (04-Apr-1997) ** ** This module uses a rule-based rewriting engine (based on a ** regular-expression parser) to rewrite requested URLs on the fly. --- 64,70 ---- ** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___| ** |_____| ** ! ** URL Rewriting Module, Version 3.0.4 (17-Apr-1997) ** ** This module uses a rule-based rewriting engine (based on a ** regular-expression parser) to rewrite requested URLs on the fly. 1.26 +15 -16 apache/src/mod_rewrite.c Index: mod_rewrite.c =================================================================== RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C3 -r1.25 -r1.26 *** mod_rewrite.c 1997/04/12 04:19:49 1.25 --- mod_rewrite.c 1997/04/16 06:07:44 1.26 *************** *** 61,67 **** ** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___| ** |_____| ** ! ** URL Rewriting Module, Version 3.0.3 (08-Apr-1997) ** ** This module uses a rule-based rewriting engine (based on a ** regular-expression parser) to rewrite requested URLs on the fly. --- 61,67 ---- ** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___| ** |_____| ** ! ** URL Rewriting Module, Version 3.0.4 (15-Apr-1997) ** ** This module uses a rule-based rewriting engine (based on a ** regular-expression parser) to rewrite requested URLs on the fly. *************** *** 143,149 **** ** o the order of modules at (**) is the inverted order as ** given in the "Configuration" file, i.e. the last module ** specified is the first one called for each hook! ! ** The core module is allways the last! ** ** o there are two different types of result checking and ** continue processing: --- 143,149 ---- ** o the order of modules at (**) is the inverted order as ** given in the "Configuration" file, i.e. the last module ** specified is the first one called for each hook! ! ** The core module is always the last! ** ** o there are two different types of result checking and ** continue processing: *************** *** 155,165 **** ** for hook #2,#3,#7,#9: ** all hooks are run, independend of result ** ! ** o at the last stage, the core module allways ** - says "BAD_REQUEST" if r->filename does not begin with "/" ** - prefix URL with document_root or replaced server_root ** with document_root and sets r->filename ! ** - allways return a "OK" independed if the file really exists ** or not! ** */ --- 155,165 ---- ** for hook #2,#3,#7,#9: ** all hooks are run, independend of result ** ! ** o at the last stage, the core module always ** - says "BAD_REQUEST" if r->filename does not begin with "/" ** - prefix URL with document_root or replaced server_root ** with document_root and sets r->filename ! ** - always return a "OK" independed if the file really exists ** or not! ** */ *************** *** 948,955 **** /* skip 'scheme:' */ for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++) ; ! /* skip '//' */ ! cp += 2; /* skip host part */ for ( ; *cp != '/' && *cp != '\0'; cp++) ; --- 948,955 ---- /* skip 'scheme:' */ for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++) ; ! /* skip '://' */ ! cp += 3; /* skip host part */ for ( ; *cp != '/' && *cp != '\0'; cp++) ; *************** *** 992,998 **** /* Hack because of underpowered API: passing the current rewritten filename through to other URL-to-filename handlers just as it were the requested URL. This is to enable ! post-processing by mod_alias, etc. which allways act on r->uri! The difference here is: We do not try to add the document root */ r->uri = pstrdup(r->pool, r->filename+12); --- 992,998 ---- /* Hack because of underpowered API: passing the current rewritten filename through to other URL-to-filename handlers just as it were the requested URL. This is to enable ! post-processing by mod_alias, etc. which always act on r->uri! The difference here is: We do not try to add the document root */ r->uri = pstrdup(r->pool, r->filename+12); *************** *** 1036,1042 **** strncpy(docroot, cp, sizeof(docroot)-1); EOS_PARANOIA(docroot); ! /* allways NOT have a trailing slash */ l = strlen(docroot); if (docroot[l-1] == '/') { docroot[l-1] = '\0'; --- 1036,1042 ---- strncpy(docroot, cp, sizeof(docroot)-1); EOS_PARANOIA(docroot); ! /* always NOT have a trailing slash */ l = strlen(docroot); if (docroot[l-1] == '/') { docroot[l-1] = '\0'; *************** *** 1176,1183 **** /* skip 'scheme:' */ for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++) ; ! /* skip '//' */ ! cp += 2; if ((cp = strchr(cp, '/')) != NULL) { rewritelog(r, 2, "[per-dir %s] trying to replace prefix %s with %s", dconf->directory, dconf->directory, dconf->baseurl); cp2 = subst_prefix_path(r, cp, dconf->directory, dconf->baseurl); --- 1176,1183 ---- /* skip 'scheme:' */ for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++) ; ! /* skip '://' */ ! cp += 3; if ((cp = strchr(cp, '/')) != NULL) { rewritelog(r, 2, "[per-dir %s] trying to replace prefix %s with %s", dconf->directory, dconf->directory, dconf->baseurl); cp2 = subst_prefix_path(r, cp, dconf->directory, dconf->baseurl); *************** *** 1193,1200 **** /* skip 'scheme:' */ for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++) ; ! /* skip '//' */ ! cp += 2; /* skip host part */ for ( ; *cp != '/' && *cp != '\0'; cp++) ; --- 1193,1200 ---- /* skip 'scheme:' */ for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++) ; ! /* skip '://' */ ! cp += 3; /* skip host part */ for ( ; *cp != '/' && *cp != '\0'; cp++) ; *************** *** 1264,1270 **** if ((cp = document_root(r)) != NULL) { prefix = pstrdup(r->pool, cp); ! /* allways NOT have a trailing slash */ l = strlen(prefix); if (prefix[l-1] == '/') { prefix[l-1] = '\0'; --- 1264,1270 ---- if ((cp = document_root(r)) != NULL) { prefix = pstrdup(r->pool, cp); ! /* always NOT have a trailing slash */ l = strlen(prefix); if (prefix[l-1] == '/') { prefix[l-1] = '\0'; *************** *** 2873,2888 **** output = input; ! /* first, remove the local directory prefix */ strncpy(matchbuf, match, sizeof(matchbuf)-1); EOS_PARANOIA(matchbuf); - /* allways have a trailing slash */ l = strlen(matchbuf); if (matchbuf[l-1] != '/') { matchbuf[l] = '/'; matchbuf[l+1] = '\0'; l++; } if (strncmp(input, matchbuf, l) == 0) { rewritelog(r, 5, "strip matching prefix: %s -> %s", output, output+l); output = pstrdup(r->pool, output+l); --- 2873,2888 ---- output = input; ! /* first create a match string which always has a trailing slash */ strncpy(matchbuf, match, sizeof(matchbuf)-1); EOS_PARANOIA(matchbuf); l = strlen(matchbuf); if (matchbuf[l-1] != '/') { matchbuf[l] = '/'; matchbuf[l+1] = '\0'; l++; } + /* now compare the prefix */ if (strncmp(input, matchbuf, l) == 0) { rewritelog(r, 5, "strip matching prefix: %s -> %s", output, output+l); output = pstrdup(r->pool, output+l); *************** *** 2890,2896 **** /* and now add the base-URL as replacement prefix */ strncpy(substbuf, subst, sizeof(substbuf)-1); EOS_PARANOIA(substbuf); - /* allways have a trailing slash */ l = strlen(substbuf); if (substbuf[l-1] != '/') { substbuf[l] = '/'; --- 2890,2895 ----