I used to be on shared hosting with cPanel. I had multiple subdomains that all pointed to different locations:
a.domain.com -> /www/versions/2
b.domain.com -> /www/versions/3
c.domain.com -> /www/versions/3
d.domain.com -> /www/versions/1
I did this by using cPanel to create the subdomain every time, then set the document root for each of them. That worked fine...using different document roots let me easily include files without worrying about which version to include them from.
I could do this:
instead of this:
include $_SERVER['document_root'] . '/www/versions/' . $version . '/file.php';
Now I've moved over to a VPS and want to do this right. Individually setting up subdomains is slow, so I intend to use a wildcard so that all subdomains point to my server. I don't think I can set different document roots this way, though. I have an entry in the database for each sudomain with a column for version...what's the best way to set this up?
I'm thinking that I hit the database to check the version, then do something like this, but I'm not confident it's the right way:
define('CLIENT_DOCUMENT_ROOT', $_SERVER['document_root'] . '/www/versions/' . $version);
Edit: I should add that this all has to be done automatically. I can't edit the http.conf and restart Apache every time a new subdomain is added.