我在项目中使用了一些子域,我希望主要的营销网站接受www以及空白子域
http://www.example.com和http://example.com
我如何用symfony做到这一点?
这是我目前的设定
_main:
resource: routing.yml
incompass_sterilization:
host: spd.casechek-dev.com
resource: "@IncompassSterilizationBundle/Resources/config/routes.yml"
incompass_printing:
host: labels.casechek-dev.com
resource: "@IncompassPrintingBundle/Resources/config/routes.yml"
incompass_admin:
host: admin.casechek-dev.com
resource: "@IncompassAdminBundle/Resources/config/routes.yml"
incompass_web:
host: www.casechek-dev.com
resource: "@IncompassWebBundle/Resources/config/routes.yml"
我在这里查看了文档http://symfony.com/doc/current/components/routing/hostname_pattern.html,但我只能看到如何设置存在的不同子域,无法解决如何使用空子域的问题。
编辑复制路由不起作用,我无法获得多个路由来使用同一控制器。这是2个未能解决问题的示例
使用相同的路由文件
incompass_web:
host: www.casechek-dev.com
resource: "@IncompassWebBundle/Resources/config/routes.yml"
incompass_web_two:
host: casechek-dev.com
resource: "@IncompassWebBundle/Resources/config/routes.yml"
使用单独的路由文件
incompass_web:
host: www.casechek-dev.com
resource: "@IncompassWebBundle/Resources/config/routes.yml"
incompass_web_two:
host: casechek-dev.com
resource: "@IncompassWebBundle/Resources/config/routes_two.yml"
routes.yml
incompass_web_main:
type: annotation
prefix: /
resource: Incompass\WebBundle\Controller\MainController
routes_two.yml
incompass_web_main_two:
type: annotation
prefix: /
resource: Incompass\WebBundle\Controller\MainController
我可以使它起作用的唯一方法是使用不同类型的路由。
app / config / routing.yml
_main:
resource: routing.yml
incompass_sterilization:
host: spd.casechek-dev.com
resource: "@IncompassSterilizationBundle/Resources/config/routes.yml"
incompass_printing:
host: labels.casechek-dev.com
resource: "@IncompassPrintingBundle/Resources/config/routes.yml"
incompass_admin:
host: admin.casechek-dev.com
resource: "@IncompassAdminBundle/Resources/config/routes.yml"
incompass_web:
host: www.casechek-dev.com
resource: "@IncompassWebBundle/Resources/config/routes.yml"
incompass_web_two:
host: casechek-dev.com
resource: "@IncompassWebBundle/Resources/config/routes_two.yml"
IncompassWebBundle / Resources / config / routes.yml
incompass_web_main:
type: annotation
prefix: /
resource: Incompass\WebBundle\Controller\MainController
IncompassWebBundle / Resources / config / routes_two.yml
incompass_web_main_two:
path: /
defaults: { _controller: IncompassWebBundle:Main:index }
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句