Andrew Green <[EMAIL PROTECTED]> on Feb 18, 2002:

> As part of this, I'm trying to allow a prefix to the URL path to set an
> environment variable I can then use in my mod_perl programs to determine
> databases, templates etc.
>
> The vanilla httpd.conf features a line thus:
>
>    RewriteRule ^/(test|access|ewok)/(.*)$
>    http://spare.article7.co.uk:8080/page/$2 [P,E=A7_FRAMEWORK:$1,L]
>
> (ignoring the wrapping).  I also set PerlPassEnv A7_FRAMEWORK in my
> mod_perl httpd.conf -- but that environment variable always remains
> undef. The order of the P,E,L flags doesn't seem to make a difference.

As others pointed out, you cannot set envivonment variables in the
vanilla and expect them to appear out of nothing in the mod_perl server.

I have had a similar Problem and got by it like this. You can have two
RewriteRules, one in the vanilla and a corresponding in the mod_perl:

vanilla:
   RewriteRule ^/(test|access|ewok)/(.*)$
   http://spare.article7.co.uk:8080/ENV_A7_FRAMEWORK/$1/page/$2
   [P,E=A7_FRAMEWORK:$1,L]

or, if you don't need A7_FRAMEWORK in the vanilla you can omit it here:
   RewriteRule ^/(test|access|ewok)/(.*)$
   http://spare.article7.co.uk:8080/ENV_A7_FRAMEWORK/$1/page/$2
   [P,L]

mod_perl:
   RewriteRule ^/ENV_([^/]+)/([^/]+)/(.*)$ $3 [E=$1:$2,PT,L]

I agree, its a big hack, but it works :-)

HTH, Hans

Reply via email to