So I set an apache variable, and i'd like to use the value to set additional variables. This is possible, I tried various methods to get this to work
SetEnv URL_STATIC http://www.static.com
Doesn't work
SetEnv URL_STATIC_MORE %{ENV:URL_STATIC}/path/path
Doesn't work either :(
SetEnv URL_STATIC_MORE ${URL_STATIC}/path/path
Ideally, i'd like URL_STATIC_MORE to be 'http://www.static.com/path/path' when all is said and done.
UPDATE:
The long winded reason i want to do this is to create a set of links that i can use in HTML/SSI. I Don't have php on my server, and that's not under my control.
So, i'd like to be able to use
<a href="<!--#echo var="ONE_VARIABLE_FOR_URL" -->">blah</a>
rather than
<a href="<!--#echo var="ROOT_URL" --><!--#echo var="PATH_URL" -->">blah</a>
Again, I do not have PHP available to me, and I have to do this for thousands of pages, so putting this in te .htaccess makes sense. I also have multiple root urls, so my config will eventually look like:
SetEnv URL_ROOT_CUSTSVC http://customerservice.company.com
SetEnv URL_ROOT_CORPORATE http://corp.company.com
SetEnv URL_ROOT_PRODUCTS http://products.company.com
SetEnv URL_ROOT_CUSTSVC_1 ${URL_ROOT_CUSTSVC}/path/1
SetEnv URL_ROOT_CUSTSVC_2 ${URL_ROOT_CUSTSVC}/path/2
SetEnv URL_ROOT_CUSTSVC_3 ${URL_ROOT_CUSTSVC}/path/3
SetEnv URL_ROOT_CORPORATE_1 ${URL_ROOT_CORPORATE}/path/1
SetEnv URL_ROOT_CORPORATE_2 ${URL_ROOT_CORPORATE}/path/2
SetEnv URL_ROOT_CORPORATE_3 ${URL_ROOT_CORPORATE}/path/3
SetEnv URL_ROOT_PRODUCTS_1 ${URL_ROOT_PRODUCTS}/path/1
SetEnv URL_ROOT_PRODUCTS_2 ${URL_ROOT_PRODUCTS}/path/2
SetEnv URL_ROOT_PRODUCTS_3 ${URL_ROOT_PRODUCTS}/path/3
Environment variables only work with the following Apache modules:
They cannot be called with
SetEnv
because that is a directive of the mod_env module.More information: http://httpd.apache.org/docs/2.2/env.html#using
There seems to be a workaround using mod_rewrite, though the specifics depend on whether you need all three domains' variables set for all requests, or only the variables for the current domain:
If you need all of the variables set for every page, regardless of the request domain, just swap %{HTTP_HOST} for the hostname in question, and rename your variables accordingly:
Unfortunately, this isn't the most readable way to set variables according to the values of other variables. If you need readability, that will unfortunately require scripting of some sort (PHP, perl, or perhaps even shell, if you have that kind of access - which you've already said you do not).
But hey, if readability isn't an issue, this should work just fine!