douwei7976 2013-11-25 22:41
浏览 25
已采纳

Symfony2主机名路由

I'm using hostname routing dependent on subdomain.

What I want to do is have two separate routings. When I'm running off www.example.com, then it uses one routing file, and if any other subdomain such as subdomain1.example.com or subdomain2.examples (etc etc), then it runs off another routing file.

My routing is as follows (yml):

route_www:
    resource: "@AcmeBundle/Resources/config/routing/www/routing.yml"
    host: www.%base_host%

route_sites:
    resource: "@AcmeBundle/Resources/config/routing/sites/routing.yml"

Now this works to a point. I am using FOSUserBundle and I have all these routes in the route_sites, but www.example.com/register for example is still viewable as www is still valid for route_sites. Is there anyway possibly using regex, to prevent subdomain www from using the route_sites route.

Hope someone can help

  • 写回答

2条回答 默认 最新

  • doq13207 2013-11-26 07:26
    关注

    see this http://symfony.com/doc/current/components/routing/hostname_pattern.html

    use a placeholder, then you can use regex in the requirments

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

报告相同问题?

悬赏问题

  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata