After doing quite a lot of searching on google and here, I have not been able to find a solution to my problem.
I used this article to learn how to create variables inside my vhost. It requires mod_define to be installed.
I have a number of developers in my team who are working on the same project and all need to have the same settings applied to their vhosts. Modifying everyone's file is quite painful. So I have created a file called redirects.conf and included it into everyone's vhost. This file does not need to know about the DEV_DIR variable defined inside each vhost, so it works fine.
Example Developer vhost:
<VirtualHost devenv:80>
Define DEV_DIR developer-name
DocumentRoot /export/www/development/${DEV_DIR}/myproject/
ServerName pavan-myproject.dev.mydomain.co.nz
Include /etc/httpd/conf/common/aliases.conf
Include /etc/httpd/conf/common/rewrites.conf
</VirtualHost>
The aliases.conf file that I have included (or tried to) needs to be aware of and evaluate the value of the DEV_DIR variable.
Aliases file the gets included:
Alias /secure/assests /export/www/development/${DEV_DIR}/myproject/assets/
Alias /secure/shareddata /export/script/data/shareddata
After including this file, when I do a configtest, I get this error:
[error] mod_define: Variable 'DEV_DIR' not defined: file /etc/httpd/conf/common/aliases.conf, line 1
However, when I do not include that file and put the aliases straight into the vhost, it evaluates the DEV_DIR variable just fine (I have tried using both notations: ${DEV_DIR} as well as $DEV_DIR and both work). Doing this still requires changes to everyone's vhost. I would like to manage it using a single file.
I want to define variables with VirtualHost scope and have them available in the included files.
How do I get the aliases.conf or for that matter any other include file to evaluate the variables defined in the vhost that includes it?
What other solution can I use to implement such a functionality?
Can you please help me or link me to a solution if this question has been asked and answered elsewhere.