I have a php application my_application
, that needs to be ran in three specific ways (namely, dev
, test
, and prod
) by httpd.
That very application is deployed many times, one for each client (with its own subdomain);
So, in the end I have that kinds of URLs:
dev-client1.myapp.mycompany.com
test-client1.myapp.mycompany.com
client1.myapp.mycompany.com
dev-client2.myapp.mycompany.com
test-client2.myapp.mycompany.com
client2.myapp.mycompany.com
And for each of these domains, I have a apache virtual block, when all I would need is a way to specify two configuration files, and the URL associated. (One for the client configuration, one for the test-dev-prod configuration).
What is the proper way of reducing the copy and paste of httpd conf in this scenario ?
for instance, a way of doing that :
register_myapp("dev-client1.myapp.mycompany.com", "myapp.php?db_access=client1.ini&configuration=dev");
or
register_myapp("dev-client1.myapp.mycompany.com", "myapp.php", "client1.ini", "dev");
or something like that, instead of :
<VirtualHost *:80>
DocumentRoot "/var/www/myapp"
ServerName dev-client1.myapp.mycompany.com
<Directory "/var/www/myapp">
AllowOverride none
Options Indexes FollowSymLinks
Require all granted
</Directory>
RewriteEngine On
RewriteRule ^.*$ start.php?client=client1.ini&version=dev
</VirtualHost>
duplicated 3n times.
Edit : Currently, my configuration is in fact :
RewriteRule ^.*$ client1/start_dev.php
But that doesn't satisfy me either, because it makes too many duplication as well.