I'd like to set up multiple domain names to use the same framework, but I can't seem to get zend's router to bend to my will.
There are plenty of examples using subdomains, but trying to make them work for an entire domain doesn't seem to work as I would expect it to.
Here's the closest I've come, but it doesn't seem to work:
resources.router.routes.mysite.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.mysite.route = "www.mysite.com"
resources.router.routes.mysite.defaults.module = "mysite"
resources.router.routes.mysite1.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.mysite1.route = "www.mysite1.com"
resources.router.routes.mysite1.defaults.module = "mysite1"
Any suggestions?
I've done this before by actually using different configuration files based on the current value of
$_SERVER['SERVER_NAME']
, which is configured by the web server. (HTTP_HOST
is the one sent by the client.)You could probably do the same thing in a single file by using INI file sections and inheritance.
Based upon this Nabble thread, it looks like you need to add a path route and then chain that path route to your hostname routes.
So perhaps something like:
Actually, we could probably collapse the two abstract mysiteX routes into a single abstract route using a placeholder like
:site
to stand in for themysiteX
value and set some requirements/defaults on those, but I think this conveys the idea.Not tested - actually I have never played with chained routes before - but it seems that something like this is required to make the hostname routing work.