Symfony3子域重定向

时间:2016-02-03 08:23:42

标签: php mod-rewrite subdomain yaml symfony

我有一个进入Symfony3应用程序主页的域名,例如:

http://www.domain.ext/ => /app.php/

但我想"无形重定向" (比如在mod_rewrite中)我的应用程序中的另一个路径的子域,例如:

http://subdomain.domain.ext/ => /app.php/path/for/subdomain/
http://subdomain.domain.ext/otherpath/ => /app.php/path/for/subdomain/otherpath/

我已经使用routing.yml尝试捕获(动态!)子域:

redirect_subdomain:
   path: /
   host: "{subdomain}.{domain}"
   defaults:
      _controller: AppBundle:Redirecting:subdomain
      domain: '%domain%'
      subdomain: www
   requirements:
      domain: '%domain%'
      subdomain: !(local|www)

他从未达到控制器功能。 我已将此页面用作参考:https://symfony.com/doc/master/components/routing/hostname_pattern.html#testing-your-controllers

我有没有做过什么?我还需要在php或yml文件中的其他位置定义子域以使其工作吗?

0 个答案:

没有答案