假设我有一个包含多个(子)域的网站:
我认为这应该很容易配置,所以我做了这个routing.yml:
usa:
host: "acme.com"
resource: "@WebsiteBundle/Controller/"
type: annotation
defaults:
country: "en"
netherlands:
host: "acme.nl"
resource: "@WebsiteBundle/Controller/"
type: annotation
defaults:
country: "nl"
europe:
host: "{country}.acme.eu"
resource: "@WebsiteBundle/Controller/"
type: annotation
但是,如果我运行router:debug
,则只会显示最后一条路线(在本例中为{country}.acme.eu
)。如果我更改订单,则会显示最后一个选项。
如何为所有国家/地区使用不同的(子)域?
这是因为所有路由都指向一个资源。以后的所有路由都将覆盖之前定义的路由。
但是您可以使用另一种解决方案:
main_route:
host: "{country}.acme.{domain}"
resource: "@WebsiteBundle/Controller/"
type: annotation
defaults:
country: "en"
然后在控制器之前检入一些侦听器,以获取有效的url和进程参数。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句