trouble using environment variables in rewriterules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm trying to set an environment variable in httpd.conf and then have
it available to the URL-portion of a RewriteRule in a .htaccess file.
Please could someone assist:



In httpd.conf I have this line setting the environment variable:


SetEnv       MODPERLPORT      81




and in .htaccess I want to do something like this:



RewriteEngine On
RewriteRule     foo\.cgi
http://myserver:%{ENV:MODPERLPORT}%{REQUEST_URI}    [P,L]


to have Apache proxy the request through to another Apache process
running on a different port, but it doesn't seem like any environment
variables are available in the URL portion of the rule.


I've also tried to do things like this:


RewriteEngine   On
RewriteCond     %{ENV:MODPERLPORT}      ([0-9]+)
RewriteRule      foo\.cgi
http://myserver:%1%{REQUEST_URI}    [P,L]


but the condition fails, even though the environment variable is set
if I look at a simple dump of the environment e.g. env.cgi through a
browser.

So far the only hacky way I can get this to work is to set a built-in
variable to the value I need, e.g.:

httpd.conf:

ServerAdmin    81

.htaccess

RewriteEngine On
RewriteRule     foo\.cgi
http://myserver:%{SERVER_ADMIN}%{REQUEST_URI}   [P,L]


but that's clearly a very poor solution for many reasons, not least
that I need the modperlport to vary for different environments without
the .htaccess file having to change for each environment.


Can anyone advise if there's a better/correct way to set customised
environment variables and then de-reference them within the URL
portion of a rewrite rule?

Thanks.
Jeremy



www.jeremyjones.com

---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux