I had this almost working several hours ago, but I can’t seem to get all the mod-rewrite stuff working right for Zend.
Given this directory structure:
/home/branches/branch1/public/index.php
/home/branches/branch2/public/index.php
/home/branches/branch3/public/index.php
How can I access these like so:
branch1.branch.example.com
branch2.branch.example.com
branch3.branch.example.com
Without having to hardcode in each branch?
Here’s my starting point (source), (I somehow can’t even get this to work at the moment, but I swear it was working this morning, ha!).
ServerAlias *.branch.example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} .* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.branch\.example\.com
RewriteCond /home/branches/%1/public
RewriteRule ^(.*) /%1/$1 [L]
(Side note: I’m actually working with a huge codebase using old alpha version of ZF that uses /www/errors.php as a bootstrap instead of /public/index.php, (and might even need some different rewrite rules than the current version) but I modified the above code to fit the current ZF setup)
Have you configured a wildcard subdomain (for routing purposes)? It won’t work unless you do.
I also think this line won’t work:
I think that your last line needs to be something like this: