Apache 将子域的虚拟主机链接到ZF2特定模块

Apache 将子域的虚拟主机链接到ZF2特定模块,apache,zend-framework2,virtualhost,Apache,Zend Framework2,Virtualhost,我可以将虚拟主机链接到zf2中的特定模块吗? 我希望我的虚拟主机dev-api.mydomain.com直接指向dev-api.mydomain.com/index.php/api。我也尝试过使用.htaccess,但没有机会 有什么建议吗 编辑 这对我有用 如果您使用的是ZF2,那么您需要在虚拟主机对话中指出/public/的任何方式。 因此,让我们看看虚拟confg,下面是您的解决方案:如果您希望api模块在默认情况下直接出现在域名上。zf2/confg/application.confg>

我可以将虚拟主机链接到zf2中的特定模块吗? 我希望我的虚拟主机dev-api.mydomain.com直接指向dev-api.mydomain.com/index.php/api。我也尝试过使用.htaccess,但没有机会

有什么建议吗

编辑

这对我有用

如果您使用的是ZF2,那么您需要在虚拟主机对话中指出/public/的任何方式。 因此,让我们看看虚拟confg,下面是您的解决方案:如果您希望api模块在默认情况下直接出现在域名上。zf2/confg/application.confg>>

'modules' => array(
    'Application',//default module
    'APi',//your module

),
'module_listener_options' => array(
    'module_paths' => array(
        './module',
        './vendor'
    ),
    'config_glob_paths' => array(
        'config/autoload/{,*.}{global,local}.php'
    )
)
然后转到application/confg/module.config.php:


你可以尝试路由\本文介绍的Zend\Mvc\Router\Http\Hostname将帮助减少可能的复制
'router' => array(
    'routes' => array(
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Api\Controller\Index',//**your changes goes here**
                    'action'     => 'index',
                ),
            ),
        ),

        'application' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/application',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\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(
                        ),
                    ),
                ),
            ),
        ),
    ),
),