You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by RĂ¼diger Kuhlmann <ta...@gmx.de> on 2000/08/08 10:10:00 UTC

Re: mod_rewrite/6262: mod_rewrite does not set environment varibles proplerly [fix]

The following reply was made to PR mod_rewrite/6262; it has been noted by GNATS.

From: =?iso-8859-1?Q?R=FCdiger_Kuhlmann?= <ta...@gmx.de>
To: Chrs Hostetter <ch...@cnet.com>, apbugs@Apache.Org
Cc: submit@bugz.apache.org
Subject: Re: mod_rewrite/6262: mod_rewrite does not set environment varibles proplerly [fix]
Date: Tue, 8 Aug 2000 10:01:59 +0200

 According to the documentation of mod_rewrite, one can set environment
 variables via RewriteRules that can later be used in SSI, cgis or other
 RwriteRules.
 
 But in practice, this doesn't work: Given for example
 
 RewriteRule B A [E:A=A]
 RewriteRule C B [E:B=B]
 RewriteRule D C [E:C=C]
 RewriteRule E D [E:D=D]
 RewriteRule F E [E:E=E]
 
 you can easily see with <--#printenv --> what went wrong: After every cycle
 through the RewriteRules, a new request is startet. For this, the
 environment variables are copied - but renamed by prefixing REDIRECT_ (which
 accumulate in the example above)
 
 Proposed fix: (no diff, sorry)
 
 in src/main/httpd_request.c, around line 1260, in rename_original_env(),
 before the loop:
 --snip--
     for (i = 0; i < env_arr->nelts; ++i) {
         if (!elts[i].key)
             continue;
         ap_table_setn(new, ap_pstrcat(p, "REDIRECT_", elts[i].key, NULL),
                   elts[i].val);
     }
 --snip--
 add another loop that keeps the variable names unchanged:
 --snap--
     for (i = 0; i < env_arr->nelts; ++i) {
         if (!elts[i].key)
             continue;
         ap_table_setn(new, elts[i].key, elts[i].val);
     }
 --snap--
 
 By that you can access the variables in the documented way, plus as a bonus
 you have access to the state of the variables in earlier cycles.