2008年9月10日星期三

[fw-mvc] How to use hostnames within zend router properly

Hi everyone!
I hope someone can help me with this little problem. I am trying to
create 4 (almost identical) websites with the same backend. Each
website is located at a different subdomain (but the same domain).
I read in the ZF documentation that you can use hostname detection in
Zend router to map each subdomain.
I've tried the following code, directly from the ZF documentation:

$route = new Zend_Controller_Router_Route(
array(
'host' => 'blog.mysite.com',
'path' => 'archive'
),
array(
'module' => 'blog',
'controller' => 'archive',
'action' => 'index'
)
);
$router->addRoute('archive', $route);

But that'll give a array to string conversion error. So I guess the
documentation isn't perfect just yet ;-)
Then I tried:

site.type = "Zend_Controller_Router_Route_Hostname"
site.route = "info.domain.com"
site.defaults.site = info
site.defaults.module = site
site.defaults.controller = index
site.defaults.action = index

This works great. The problem is, however, that none of the automatic
route mapping (e.g. http://info.domain.com/signup to
controller=signup, action=index) work anymore as the rule above
overrides any other. If I define another rule, it will override the
hostname mapping and I will lose the parameter 'site'.

So, what I would like to have is hostname mapping independent of any
other url mapping.

Does anyone know how to solve this?

Thanks for helping!

p.s. I am using Zend Framework 1.6.0

没有评论: