2016-07-02 21 views
0

我已經安裝了zend框架應用程序,它可以正常工作,直到向其中添加多個模塊爲止。問題出在我設置的虛擬主機上。場景如下:具有多個zend模塊的虛擬主機

我有兩個站點:cms.localhostsite.localhost。 這兩個虛擬主機都指向同一個公共文件夾,但我希望每個都使用它們各自的模塊。是否有虛擬主機指令,我可以告訴cms.localhost使用Cms模塊和site.localhost來使用我在zend項目中設置的Site模塊?

回答

0

您可以使用主機名路由類型來實現此目的。你可以閱讀它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__'選項設置默認的命名空間,相應的主機名。

+0

@CraigStandish我更新了我的答案,我忘了用關鍵的''options''把它包裝成一個數組...... – Wilt