私はWebとCmsの2つのモジュールを使ってプロジェクトを進めています。これらのモジュールでサブドメインを使用したいと思います。Zend Framework 2モジュールからサブドメインへのマッピング
mydomain.com
- > Webモジュール
cms.mydomain.com
- >のCMSモジュール
私は、各モジュールにmodule.config.phpファイルの下に使用
Webモジュール - > module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Web\Controller\Index' => 'Web\Controller\IndexController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'mydomain.com',
'defaults' => array(
'__NAMESPACE__' => 'Web\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Index',
'action' => 'index',
),
),
),
),
),
),
),
'view_manager' => array(
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/default.phtml',
),
'template_path_stack' => array(
'web' => __DIR__ . '/../view',
),
),
'session' => array(
'remember_me_seconds' => 2419200,
'use_cookies' => true,
'cookie_httponly' => true,
),
);
?>
CMSモジュール - > module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Cms\Controller\Index' => 'Cms\Controller\IndexController',
'Cms\Controller\User' => 'Cms\Controller\UserController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'cms' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'cms.mydomain.dev',
'defaults' => array(
'__NAMESPACE__' => 'Cms\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Index',
'action' => 'index',
),
),
),
),
),
),
),
'view_manager' => array(
'template_map' => array(
'layout/default' => __DIR__ . '/../view/layout/default.phtml',
'layout/system' => __DIR__ . '/../view/layout/system_layout.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
'cms' => __DIR__ . '/../view/script',
),
),
'session' => array(
'remember_me_seconds' => 2419200,
'use_cookies' => true,
'cookie_httponly' => true,
),
);
?>
これは期待どおりに機能しません。 Webモジュールmydomain.com
はレイアウトを表示していますが、コンテンツが表示されていません。 CMSはまた私がcms.mydomain.com
を試してみると、Webモジュールを示しています。問題がどこにあるのか教えてください。