Setting CGI environment variables, dynamically, from httpd.conf leveragingexising variables

Setting CGI environment variables, dynamically, from httpd.conf leveragingexising variables

am 28.09.2010 16:02:22 von david.donnan

--------------030708090309050006020409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

OS: Windoze httpd: 2.2.1.6

Hello everybody and thanks for taking the time to read this posting.

I apologize, in advance, if I'm a novice. I've looked extensively and
have not found a solution -- perhaps I've completely misunderstood.

I need to instantiate a CGI environment variable $SMUSER with the
contents of
an existing environment variable, say, $REMOTE_USER.

I'm testing with setenv.pl to display the CGI environment.

I've tried 3 techniques:

Technique 1: Rewrite
--------------------

RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

Result from my browser (setenv.pl):

SMUSER=""

Question 1: The syntax is incredibly cryptic. Where might I look to help
me understand the %, e, {} etc.

Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

Result: DAVESETENV="text"

But, I've read that this is only a static string.

http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html


Technique 3. JkEnvVar.
-----------------------

If I've understood correctly, we can 'fool' HTTPD into thinking there
is a Tomcat behind and, therefore, use mod_jk.

Question 2: Am I correct ?

JkWorkersFile conf/workers.properties
JkEnvVar DAVEJKENVVAR "test"
JkLogFile "logs/mod_jk.log"
JkLogLevel debug

Result: nothing related to DAVE in the browser

Question 3: Which technique do you recommend and can you please give me
a nudge in the right direction ?

Cdlt, Dave
--------


--------------030708090309050006020409
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit






OS: Windoze httpd: 2.2.1.6



Hello everybody and thanks for taking the time to read this posting.



I apologize, in advance, if I'm a novice. I've looked extensively and
have not found a solution -- perhaps I've completely misunderstood.



I need to instantiate a CGI environment variable $SMUSER with the
contents of

an existing environment variable, say, $REMOTE_USER.



I'm testing with setenv.pl to display the CGI environment.



I've tried 3 techniques:



Technique 1: Rewrite

--------------------



RewriteEngine on



RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]

RequestHeader set my_new_header %{SMUSER}e



        Result from my browser (setenv.pl):



        SMUSER=""



Question 1: The syntax is incredibly cryptic. Where might I look to
help me understand the %, e, {} etc.



Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]



Result: SMUSER="test"


2. Technique 2: setenv DAVESETENV "text"

----------------------------------------------



    Result: DAVESETENV="text"

 

But, I've read that this is only a static string.









Technique 3. JkEnvVar.

-----------------------



If I've understood correctly, we can 'fool' HTTPD into thinking there

is a Tomcat behind and, therefore, use mod_jk.



Question 2: Am I correct ?



JkWorkersFile conf/workers.properties

JkEnvVar DAVEJKENVVAR "test"

JkLogFile "logs/mod_jk.log"

JkLogLevel debug



Result: nothing related to DAVE in the browser



Question 3: Which technique do you recommend and can you please give me
a nudge in the right direction ?



Cdlt, Dave

--------






--------------030708090309050006020409--

Re: Setting CGI environment variables, dynamically,from httpd.conf leveraging exising variables

am 28.09.2010 16:43:19 von Eric Covener

On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
wrote:
> RewriteEngine on
>
> RewriteRule .* - [E=3DSMUSER:%{$REMOTE_USER}]
> RequestHeader set my_new_header %{SMUSER}e
>
>       =A0 Result from my browser (setenv.pl):
>
>       =A0 SMUSER=3D""

I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in , which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?

>
> Question 1: The syntax is incredibly cryptic. Where might I look to help =
me
> understand the %, e, {} etc.
The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:

http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader

The syntax for mod_rewrite is midway down in the doc for RewriteRule:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule

> Mind you, it works for simple text:
>
> RewriteRule .* - [E=3DSMUSER:test]
>
> Result: SMUSER=3D"test"
>
> 2. Technique 2: setenv DAVESETENV "text"
> ----------------------------------------------
>
>   =A0 Result: DAVESETENV=3D"text"
>
> But, I've read that this is only a static string.
>
> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-varia=
ble.html

setenvif is a bit more flexible:
http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif

--=20
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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

Re: Setting CGI environment variables, dynamically,from httpd.conf leveraging exising variables

am 29.09.2010 09:34:34 von david.donnan

--------------050106020802040003050201
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello everybody.

Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !

httpd.conf:
RewriteEngine on
RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]

Result (setenv.pl):
...
SMUSER=""
...
Thanks again, Dave

PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.
------

Eric Covener wrote:
> On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
> wrote:
>
>> RewriteEngine on
>>
>> RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
>> RequestHeader set my_new_header %{SMUSER}e
>>
>> Result from my browser (setenv.pl):
>>
>> SMUSER=""
>>
>
> I think the $ is extraneous and causing problems. Another potential
> problem -- See the "lookahead" feature to figure out REMOTE_USER when
> your RewriteRules are running in a phase before REMOTE_USER is set!
>
> You may be able to wrap your rules in , which makes the
> Rewrite occur a little bit later, and might let some rules like this
> work better.
>
> Finally, why do you want to set the environment variable in a request
> header? Is this just some debug you added along the way, or your
> ultimate goal?
>
>
>> Question 1: The syntax is incredibly cryptic. Where might I look to help me
>> understand the %, e, {} etc.
>>
> The variable syntax for RequestHeader is defined in a table at the
> bottom of the Header directive:
>
> http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader
>
> The syntax for mod_rewrite is midway down in the doc for RewriteRule:
> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>
>
>> Mind you, it works for simple text:
>>
>> RewriteRule .* - [E=SMUSER:test]
>>
>> Result: SMUSER="test"
>>
>> 2. Technique 2: setenv DAVESETENV "text"
>> ----------------------------------------------
>>
>> Result: DAVESETENV="text"
>>
>> But, I've read that this is only a static string.
>>
>> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html
>>
>
> setenvif is a bit more flexible:
> http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif
>
>


--------------050106020802040003050201
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit







Hello everybody.



Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !



httpd.conf:

    RewriteEngine on

    RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]



Result (setenv.pl):

    ...

    SMUSER="<my-LDAP-userid :-) >"

    ...

Thanks again, Dave



PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.

------



Eric Covener wrote:
cite="mid:AANLkTi=_EdQytfNx4Wu9qsMhyRXHcbxh1BfVY59_v1nY@mail .gmail.com"
type="cite">

On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
wrote:


RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

        Result from my browser (setenv.pl):

        SMUSER=""



I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in <Directory>, which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?



Question 1: The syntax is incredibly cryptic. Where might I look to help me
understand the %, e, {} etc.


The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:



The syntax for mod_rewrite is midway down in the doc for RewriteRule:




Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

    Result: DAVESETENV="text"

But, I've read that this is only a static string.





setenvif is a bit more flexible:









--------------050106020802040003050201--

RewriteRule E=SMUSER:%{LA-U:REMOTE_USER} works but not E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}

am 29.09.2010 14:18:11 von david.donnan

--------------020506040305040804060607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello again. I hope I've not overstayed my welcome.

RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for both 80
and 443 (SSL)

However, the following doesn't work for either (I understand why it
doesn't work for port 80 :-)

RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]

Nor the following:

RewriteRule .* - [E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}] #
note L A-F, not LA-U

I've done my reading but have not found the definitive list of supported
variables.

I found a table at the following link, search for %{ NAME_OF_VARIABLE }

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule

Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing something ?

Any help would be greatly appreciated, Dave
-------

David (Dave) Donnan wrote:
> Hello everybody.
>
> Eric, thanks for the rapide response. I took the $PATH of least
> resistance, corrected Technique #1, and now it WORKS !
>
> httpd.conf:
> RewriteEngine on
> RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]
>
> Result (setenv.pl):
> ...
> SMUSER=""
> ...
> Thanks again, Dave
>
> PS: I had no luck with setenvif but I'm more than happy with the
> RewriteRule.
> ------
>
> Eric Covener wrote:
>> On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
>> wrote:
>>
>>> RewriteEngine on
>>>
>>> RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
>>> RequestHeader set my_new_header %{SMUSER}e
>>>
>>> Result from my browser (setenv.pl):
>>>
>>> SMUSER=""
>>>
>>
>> I think the $ is extraneous and causing problems. Another potential
>> problem -- See the "lookahead" feature to figure out REMOTE_USER when
>> your RewriteRules are running in a phase before REMOTE_USER is set!
>>
>> You may be able to wrap your rules in , which makes the
>> Rewrite occur a little bit later, and might let some rules like this
>> work better.
>>
>> Finally, why do you want to set the environment variable in a request
>> header? Is this just some debug you added along the way, or your
>> ultimate goal?
>>
>>
>>> Question 1: The syntax is incredibly cryptic. Where might I look to help me
>>> understand the %, e, {} etc.
>>>
>> The variable syntax for RequestHeader is defined in a table at the
>> bottom of the Header directive:
>>
>> http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader
>>
>> The syntax for mod_rewrite is midway down in the doc for RewriteRule:
>> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>>
>>
>>> Mind you, it works for simple text:
>>>
>>> RewriteRule .* - [E=SMUSER:test]
>>>
>>> Result: SMUSER="test"
>>>
>>> 2. Technique 2: setenv DAVESETENV "text"
>>> ----------------------------------------------
>>>
>>> Result: DAVESETENV="text"
>>>
>>> But, I've read that this is only a static string.
>>>
>>> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html
>>>
>>
>> setenvif is a bit more flexible:
>> http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif
>>
>>
>


--------------020506040305040804060607
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit







Hello again. I hope I've not overstayed my welcome.

RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for
both 80 and 443 (SSL)


However, the following doesn't work for either (I understand why it
doesn't work for port 80 :-)

RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]


Nor the following:

RewriteRule .* -
[E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}]      # note L A-F, not LA-U


I've done my reading but have not found the definitive list of
supported variables.



I found a table at the following link, search for %{ NAME_OF_VARIABLE 


href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule


Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing
something ?



Any help would be greatly appreciated, Dave

-------



David (Dave) Donnan wrote:
cite="mid:7903_1285745677_4CA2EC0D_7903_27653_1_4CA2EC0A.208 0409@thalesgroup.com"
type="cite">

Hello everybody.



Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !



httpd.conf:

    RewriteEngine on

    RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]



Result (setenv.pl):

    ...

    SMUSER="<my-LDAP-userid :-) >"

    ...

Thanks again, Dave



PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.

------



Eric Covener wrote:
cite="mid:AANLkTi=_EdQytfNx4Wu9qsMhyRXHcbxh1BfVY59_v1nY@mail .gmail.com"
type="cite">
On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
href="mailto:david.donnan@thalesgroup.com"><david.donnan@thalesgroup.com > wrote:


RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

        Result from my browser (setenv.pl):

        SMUSER=""



I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in <Directory>, which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?



Question 1: The syntax is incredibly cryptic. Where might I look to help me
understand the %, e, {} etc.


The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:

href="http://httpd.apache.org/docs/current/mod/mod_headers.h tml#header">http://httpd.apache.org/docs/current/mod/mod_hea ders.html#header

The syntax for mod_rewrite is midway down in the doc for RewriteRule:
href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule



Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

    Result: DAVESETENV="text"

But, I've read that this is only a static string.

href="http://www.usenet-forums.com/apache-web-server/10179-s etenv-dynamic-variable.html">http://www.usenet-forums.com/ap ache-web-server/10179-setenv-dynamic-variable.html



setenvif is a bit more flexible:
href="http://httpd.apache.org/docs/current/mod/mod_setenvif. html#setenvif">http://httpd.apache.org/docs/current/mod/mod_ setenvif.html#setenvif











--------------020506040305040804060607--

Re: RewriteRule E=SMUSER:%{LA-U:REMOTE_USER} works but not E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}

am 29.09.2010 14:29:10 von david.donnan

--------------050106030201020908060209
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

My bad, it works as follows (worth noting for the archives).

RewriteRule .* - [E=SMUSER:%{SSL:SSL_CLIENT_S_DN_Email}]

Cdlt, Dave
------
David (Dave) Donnan wrote:
> Hello again. I hope I've not overstayed my welcome.
>
> RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for both 80
> and 443 (SSL)
>
> However, the following doesn't work for either (I understand why it
> doesn't work for port 80 :-)
>
> RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]
>
> Nor the following:
>
> RewriteRule .* - [E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}] #
> note L A-F, not LA-U
>
> I've done my reading but have not found the definitive list of
> supported variables.
>
> I found a table at the following link, search for %{ NAME_OF_VARIABLE }
>
> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>
> Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing
> something ?
>
> Any help would be greatly appreciated, Dave
> -------
>
> David (Dave) Donnan wrote:
>> Hello everybody.
>>
>> Eric, thanks for the rapide response. I took the $PATH of least
>> resistance, corrected Technique #1, and now it WORKS !
>>
>> httpd.conf:
>> RewriteEngine on
>> RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]
>>
>> Result (setenv.pl):
>> ...
>> SMUSER=""
>> ...
>> Thanks again, Dave
>>
>> PS: I had no luck with setenvif but I'm more than happy with the
>> RewriteRule.
>> ------
>>
>> Eric Covener wrote:
>>> On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
>>> wrote:
>>>
>>>> RewriteEngine on
>>>>
>>>> RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
>>>> RequestHeader set my_new_header %{SMUSER}e
>>>>
>>>> Result from my browser (setenv.pl):
>>>>
>>>> SMUSER=""
>>>>
>>>
>>> I think the $ is extraneous and causing problems. Another potential
>>> problem -- See the "lookahead" feature to figure out REMOTE_USER when
>>> your RewriteRules are running in a phase before REMOTE_USER is set!
>>>
>>> You may be able to wrap your rules in , which makes the
>>> Rewrite occur a little bit later, and might let some rules like this
>>> work better.
>>>
>>> Finally, why do you want to set the environment variable in a request
>>> header? Is this just some debug you added along the way, or your
>>> ultimate goal?
>>>
>>>
>>>> Question 1: The syntax is incredibly cryptic. Where might I look to help me
>>>> understand the %, e, {} etc.
>>>>
>>> The variable syntax for RequestHeader is defined in a table at the
>>> bottom of the Header directive:
>>>
>>> http://httpd.apache.org/docs/current/mod/mod_headers.html#he ader
>>>
>>> The syntax for mod_rewrite is midway down in the doc for RewriteRule:
>>> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#re writerule
>>>
>>>
>>>> Mind you, it works for simple text:
>>>>
>>>> RewriteRule .* - [E=SMUSER:test]
>>>>
>>>> Result: SMUSER="test"
>>>>
>>>> 2. Technique 2: setenv DAVESETENV "text"
>>>> ----------------------------------------------
>>>>
>>>> Result: DAVESETENV="text"
>>>>
>>>> But, I've read that this is only a static string.
>>>>
>>>> http://www.usenet-forums.com/apache-web-server/10179-setenv- dynamic-variable.html
>>>>
>>>
>>> setenvif is a bit more flexible:
>>> http://httpd.apache.org/docs/current/mod/mod_setenvif.html#s etenvif
>>>
>>>
>>
>


--------------050106030201020908060209
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit







My bad, it works as follows (worth noting for the archives).

RewriteRule .* - [E=SMUSER:%{SSL:SSL_CLIENT_S_DN_Email}]


Cdlt, Dave

------

David (Dave) Donnan wrote:


Hello again. I hope I've not overstayed my welcome.

RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}] works for
both 80 and 443 (SSL)


However, the following doesn't work for either (I understand why it
doesn't work for port 80 :-)

RewriteRule .* - [E=SMUSER:%{LA-U:SSL_CLIENT_S_DN_EMAIL}]


Nor the following:

RewriteRule .* -
[E=SMUSER:%{LA-F:SSL_CLIENT_S_DN_EMAIL}]      # note L A-F, not LA-U


I've done my reading but have not found the definitive list of
supported variables.



I found a table at the following link, search for %{ NAME_OF_VARIABLE 


href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule


Is SSL_CLIENT_S_DN_EMAIL not supported or am I, perhaps, missing
something ?



Any help would be greatly appreciated, Dave

-------



David (Dave) Donnan wrote:
cite="mid:7903_1285745677_4CA2EC0D_7903_27653_1_4CA2EC0A.208 0409@thalesgroup.com"
type="cite">
http-equiv="Content-Type">
Hello everybody.



Eric, thanks for the rapide response. I took the $PATH of least
resistance, corrected Technique #1, and now it WORKS !



httpd.conf:

    RewriteEngine on

    RewriteRule .* - [E=SMUSER:%{LA-U:REMOTE_USER}]



Result (setenv.pl):

    ...

    SMUSER="<my-LDAP-userid :-) >"

    ...

Thanks again, Dave



PS: I had no luck with setenvif but I'm more than happy with the
RewriteRule.

------



Eric Covener wrote:
cite="mid:AANLkTi=_EdQytfNx4Wu9qsMhyRXHcbxh1BfVY59_v1nY@mail .gmail.com"
type="cite">
On Tue, Sep 28, 2010 at 10:02 AM, David (Dave) Donnan
href="mailto:david.donnan@thalesgroup.com"><david.donnan@thalesgroup.com > wrote:


RewriteEngine on

RewriteRule .* - [E=SMUSER:%{$REMOTE_USER}]
RequestHeader set my_new_header %{SMUSER}e

        Result from my browser (setenv.pl):

        SMUSER=""



I think the $ is extraneous and causing problems. Another potential
problem -- See the "lookahead" feature to figure out REMOTE_USER when
your RewriteRules are running in a phase before REMOTE_USER is set!

You may be able to wrap your rules in <Directory>, which makes the
Rewrite occur a little bit later, and might let some rules like this
work better.

Finally, why do you want to set the environment variable in a request
header? Is this just some debug you added along the way, or your
ultimate goal?



Question 1: The syntax is incredibly cryptic. Where might I look to help me
understand the %, e, {} etc.


The variable syntax for RequestHeader is defined in a table at the
bottom of the Header directive:

href="http://httpd.apache.org/docs/current/mod/mod_headers.h tml#header">http://httpd.apache.org/docs/current/mod/mod_hea ders.html#header

The syntax for mod_rewrite is midway down in the doc for RewriteRule:
href="http://httpd.apache.org/docs/current/mod/mod_rewrite.h tml#rewriterule">http://httpd.apache.org/docs/current/mod/mo d_rewrite.html#rewriterule



Mind you, it works for simple text:

RewriteRule .* - [E=SMUSER:test]

Result: SMUSER="test"

2. Technique 2: setenv DAVESETENV "text"
----------------------------------------------

    Result: DAVESETENV="text"

But, I've read that this is only a static string.

href="http://www.usenet-forums.com/apache-web-server/10179-s etenv-dynamic-variable.html">http://www.usenet-forums.com/ap ache-web-server/10179-setenv-dynamic-variable.html



setenvif is a bit more flexible:
href="http://httpd.apache.org/docs/current/mod/mod_setenvif. html#setenvif">http://httpd.apache.org/docs/current/mod/mod_ setenvif.html#setenvif














--------------050106030201020908060209--