您可以使用主機名路由類型來實現此目的。你可以閱讀它here in the documentation。這裏是你的情況下獲得一個例子,你開始:
'router' => array(
'routes' => array(
'cms' => array(
'type' => 'hostname',
'options' => array(
'route' => 'cms.localhost',
'defaults' => array(
'__NAMESPACE__' => 'Cms\Controller',
'controller' => 'Index',
'action' => 'index',
)
),
'may_terminate' => true,
'child_routes' => array(
// your cms child routes
)
),
'site' => array(
'type' => 'hostname',
'options' => array(
'route' => 'site.localhost',
'defaults' => array(
'__NAMESPACE__' => 'Site\Controller',
'controller' => 'Index',
'action' => 'index',
)
),
'may_terminate' => true,
'child_routes' => array(
// your site child routes
)
)
)
),
在這個例子中我使用了'__NAMESPACE__'
選項設置默認的命名空間,相應的主機名。
@CraigStandish我更新了我的答案,我忘了用關鍵的''options''把它包裝成一個數組...... – Wilt