douwaif22244 2011-04-30 01:24
浏览 38
已采纳

如何让Zend Route根据域名使用不同的模块

I'd like to set up multiple domain names to use the same framework, but I can't seem to get zend's router to bend to my will.

There are plenty of examples using subdomains, but trying to make them work for an entire domain doesn't seem to work as I would expect it to.

Here's the closest I've come, but it doesn't seem to work:

resources.router.routes.mysite.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.mysite.route = "www.mysite.com"
resources.router.routes.mysite.defaults.module = "mysite"

resources.router.routes.mysite1.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.mysite1.route = "www.mysite1.com"
resources.router.routes.mysite1.defaults.module = "mysite1"

Any suggestions?

  • 写回答

2条回答 默认 最新

  • dongyongju9560 2011-04-30 07:08
    关注

    Based upon this Nabble thread, it looks like you need to add a path route and then chain that path route to your hostname routes.

    So perhaps something like:

    ; abstract routes to be used in chaining
    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"
    
    resources.router.routes.mysite.type = "Zend_Controller_Router_Route_Hostname"
    resources.router.routes.mysite.abstract = true
    resources.router.routes.mysite.route = "www.mysite.com"
    resources.router.routes.mysite.defaults.module = "mysite"
    
    resources.router.routes.mysite1.type = "Zend_Controller_Router_Route_Hostname"
    resources.router.routes.mysite1.abstract = true
    resources.router.routes.mysite1.route = "www.mysite1.com"
    resources.router.routes.mysite1.defaults.module = "mysite1"
    
    ; now the actual (non-abstract) routes are chains of the abstract ones
    resources.router.routes.mysite-plain.type = "Zend_Controller_Router_Route_Chain"
    resources.router.routes.mysite-plain.chain = "mysite,plain"
    
    resources.router.routes.mysite1-plain.type = "Zend_Controller_Router_Route_Chain"
    resources.router.routes.mysite1-plain.chain = "mysite1,plain"
    

    Actually, we could probably collapse the two abstract mysiteX routes into a single abstract route using a placeholder like :site to stand in for the mysiteX value and set some requirements/defaults on those, but I think this conveys the idea.

    Not tested - actually I have never played with chained routes before - but it seems that something like this is required to make the hostname routing work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题