【发布时间】:2014-04-17 12:16:06
【问题描述】:
我在为我的 symfony 应用程序设置主机时遇到问题。现在我们有一个域,假设它是所有四种语言的 domain.pl。所以 YML 中的规则是:
front_common:
resource: "@FrontCommonBundle/Resources/config/routing.yml"
prefix: /{_locale}
defaults: { _locale: pl }
requirements:
_locale: "[a-z]{2}"
front_common_locale:
path: /
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
_locale: pl
path: /pl
permanent: true
因此,如果有人进入 domain.pl,他/她将被重定向到 domain.pl/pl。其他页面是 domain.pl/en、domain.pl/de 等等...
现在我们得到另一个域,比如说 domain.eu,它应该只显示英文版本,所以 domain.eu 显示英文,其他人仍然重定向到 /pl /de 等。我的路由现在看起来是这样的:
front_common_eu:
host: domain.eu
resource: "@FrontCommonBundle/Resources/config/routing.yml"
prefix: /
defaults: { _locale: en }
front_common:
resource: "@FrontCommonBundle/Resources/config/routing.yml"
prefix: /{_locale}
defaults: { _locale: pl }
requirements:
_locale: "[a-z]{2}"
front_common_locale:
path: /
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
_locale: pl
path: /pl
permanent: true
当我输入 domain.pl 时,它工作正常,并将我重定向到 /pl。但是当我输入 domain.eu 时,它的工作原理相同,它将我重定向到 /pl。如果我删除 fron_common_locale 路由,我会得到 404。求助,我做错了什么?
PS。据此:Routing prefix as follows the Virtual Host 它应该可以工作...
【问题讨论】:
标签: symfony routing resources host