You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Joshua Slive <js...@gmail.com> on 2005/04/14 17:55:32 UTC

Re: [users@httpd] Re: Re: setting prefer-language as part of a rewritecond

On 4/14/05, Per Jessen <pe...@computer.org> wrote:
> SetEnvIf Request_URI ^/([a-z][a-z])/  prefer-language=$1
> SetEnvIf Remote_Addr ^(.+)$           spamtrap=$1
> 
> Given a URL like:  /xx/langtest, I would expect to have two environment variables:
> 
> spamtrap=<ip-address>
> 
> and
> 
> prefer-language=xx
> 
> What I have (according to a phpinfo() printout) is only the 'spamtrap' variable.  There is
> another set of variables all prefixed with 'REDIRECT_', including 'REDIRECT_prefer-language",
> but I suspect this is php-specific?
> 
> So, why do I get my 'spamtrap' variable set properly, but not 'prefer-language' ????  I'm
> beginning to consider a bug-report.

Not a bug.  The REDIRECT_ variables indicate that the request went
through an internal-redirect (apache did a subrequest to grab the
final document).  All the variables from before the redirect are
prepended with the REDIRECT_ thing.  spamtrap obviously gets set again
on the redirect, so it should have both a REDIRECT_ and a
non-REDIRECT_ variable.

This may also be why the RewriteRule didn't work.

Now, the question is how to avoid the internal redirect.  Again I'm
just guessing here, but I suspect that you could do this either by
replacing your RewriteRule with an Alias, or by using a full
file-system path in the target of your RewriteRule.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: Re: Re: setting prefer-language as part of a rewritecond

Posted by Per Jessen <pe...@computer.org>.
Per Jessen wrote:

> Joshua Slive wrote:
>> Now, the question is how to avoid the internal redirect.  Again I'm
>> just guessing here, but I suspect that you could do this either by
>> replacing your RewriteRule with an Alias
> 
> Hmmm, that's worth trying.

OK, using AliasMatch does the trick.  With SetEnvIf I now get 'prefer-language' set
appropriately, and AliasMatch maps /xx/ to / .

Thanks for your help Joshua - I tend to forget about the simple solutions once I'm thinking
in rewriting terms.


/Per Jessen, Zürich



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: Re: Re: setting prefer-language as part of a rewritecond

Posted by Per Jessen <pe...@computer.org>.
Joshua Slive wrote:

> Not a bug.  The REDIRECT_ variables indicate that the request went
> through an internal-redirect (apache did a subrequest to grab the
> final document).  

OK. I was wondering about that. 

> All the variables from before the redirect are prepended with the REDIRECT_ thing.  
> spamtrap obviously gets set again on the redirect, so it should have both a REDIRECT_ and a
> non-REDIRECT_ variable.

Yep, I've got both versions.

> Now, the question is how to avoid the internal redirect.  Again I'm
> just guessing here, but I suspect that you could do this either by
> replacing your RewriteRule with an Alias

Hmmm, that's worth trying.


/Per Jessen, Zürich



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org