Zend framework 我们可以为Zend framework1.11中的模块创建虚拟主机吗
目前我有一个Zend framework 我们可以为Zend framework1.11中的模块创建虚拟主机吗,zend-framework,virtualhost,Zend Framework,Virtualhost,目前我有一个zend 1.xx项目,包含三个模块module1,module2,module3 我的要求是为每个模块创建单独的虚拟主机 就像我们输入http://module1is应加载模块1,我们键入http://module2然后它应该加载项目的模块2 对于除默认值以外的模块,虚拟主机中的DocumentRoot值应该是多少 对于默认模块,../project/public可以正常工作,但对于其他模块则不行。您绝对不能使用虚拟主机来实现这一点,除非您实际将代码库拆分为每个模块(这意味着只有模
zend 1.xx
项目,包含三个模块module1
,module2
,module3
我的要求是为每个模块创建单独的虚拟主机
就像我们输入http://module1
is应加载模块1,我们键入http://module2
然后它应该加载项目的模块2
对于除默认值以外的模块,虚拟主机中的DocumentRoot
值应该是多少
对于默认模块,../project/public可以正常工作,但对于其他模块则不行。您绝对不能使用虚拟主机来实现这一点,除非您实际将代码库拆分为每个模块(这意味着只有模块1、模块2或模块3的代码副本) 您可以非常轻松地禁用(这将完全删除对应用程序的访问,我相信,我想您还没有定义自己的路由),然后创建一个链接a和一个看起来像默认路由的路由 因此:
我通过在application.ini文件中使用以下代码集实现了这一点-
; This piece of code used for rounting usoc host to default module
resources.router.routes.plain.type = "Zend_Controller_Router_Route"
resources.router.routes.plain.abstract = true
resources.router.routes.plain.route = "/:controller/:action"
resources.router.routes.plain.defaults.controller = "index"
resources.router.routes.plain.defaults.action = "index"
以上代码适用于默认模块
; This piece of code used for rounting beat host to beat module
resources.router.routes.beat.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.beat.route = "beat"
resources.router.routes.beat.defaults.module = "beat"
resources.router.routes.beat.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.beat.chains.index.route = ":controller/:action/*"
resources.router.routes.beat.chains.index.defaults.controller = "index"
resources.router.routes.beat.chains.index.defaults.action = "index"
以上代码适用于beat模块,主机名也为beat谢谢您的回复。它需要虚拟主机设置吗?不需要,基本上取决于您当前的设置。。。如果您当前的virtualhost接受不同的域,则无需更改;如果您当前的设置没有virtualhost,则所有流量都将通过此应用程序,因此没有额外的设置。。。不过,这取决于您的设置……下面是用于我的“beat”模块的代码,仍然选择默认模块布局-
$hostnameAdminRoute=new Zend\u Controller\u Router\u Route\u Hostname('beat',array('module'=>'beat')$路由器->添加路由('beat',$HOSTNAME AdminRoute->chain(新的Zend_控制器_路由器_路由(':Controller/:action/*',数组('Controller'=>'index','action'=>'index')))
原因是什么?另外,我只在默认模块的Bootstrap.php文件中添加了上述代码。您的目标是哪个url?我可以在代码中看到路由主机名,但其中没有主机。。。