Symfony 路由不适用于默认和尾随 /

Symfony route not working with default and trailing /

我开始使用 Symfony 3。测试路由,我创建了一个默认值如下:

index:
    path:     /test/{name}
    defaults: { _controller: MainBundle:Advert:index, name: maxime }

该路线适用于:

但是

知道为什么吗?谢谢

这在此处记录https://symfony.com/doc/master/routing/optional_placeholders.html

Routes with optional parameters at the end will not match on requests with a trailing slash (i.e. /blog/ will not match, /blog will match).

如果你确实需要匹配甚至 /test/ 你可以添加以下路由条目

index_trailing_slash:
    path:     /test/
    defaults: { _controller: MainBundle:Advert:index, name: maxime }