httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <rainer.j...@kippdata.de>
Subject Re: [users@httpd] Re-use of a Setenv directive
Date Wed, 20 Oct 2010 14:18:23 GMT
On 20.10.2010 14:49, S├ębastien Moretti wrote:
> Hi
>
> I have defined a SetEnv Directive this way:
> SetEnv BASE_PATH /tmp/smthg
>
> I would like to re-use this variable in another SetEnv Directive, e.g.:
> SetEnv PATHS $BASE_PATH/a:$BASE_PATH/b:$BASE_PATH/c:...
>
>
> But $BASE_PATH is not interpreted as a variable.
> I tried with quotes, back-splash, ...
>
>
> How can I re-use this variable in another SetEnv Directive ?
> Thanks

You should be able to do this via:

- Use a RewriteCond to match against the BASE_PATH variable
- Use a RewriteRuke with an ENV= flag to set PATHS using the back 
reference to the matched variable

Clumsy, but should work.

If the values are in fact static, i.e. do not depend in the request, 
virtual host etc., you can actually use the fact, that Apache allows you 
to resolve unix environment variables (not the same as Apache 
environment variables) inside the Apache configuration. The syntax is 
${VARNAME} (do not drop the curly braces).

- Set env var outside of Apache before starting:

BASE_PATH=/var/smthg
export BASE_PATH

Use variable inside Apache config:

SetEnv PATHS ${BASE_PATH}/a:${BASE_PATH}/b:${BASE_PATH}/c:...

or

<Directory ${BASE_PATH}/somesubdir>

etc.

Regards,

Rainer

---------------------------------------------------------------------
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


Mime
View raw message