Symfony2 Routes 找不到路由(多语言)


Symfony2 Routes doesn't find route (multilingual)

如果访问者输入 www.url.com/project 或 www.url.com/en/project,我想将访问者重定向到Project:index页面

不知何故,它找不到我设计的路由(是的,缓存被清除了几次)

以下是路线:

dbe_projectLang:
    path:     /project/
    defaults: { _controller: DbeDonaciBundle:Project:root }
    requirements:
        _locale: en|fr|de

dbe_project:
    resource: "@DbeDonaciBundle/Resources/config/routing/project.yml"
    prefix:     /{_locale}/project/
    requirements:
        _locale: en|fr|de

这是路由控制器<- 这个工作正常

public function rootAction(Request $request) {
    $locale = $request -> getLocale();
    return $this -> redirect($this -> generateUrl('dbe_project', array('_locale' => $locale)));
}

这是它收到的错误消息:

No route found for "GET /project/"

已经感谢您的帮助!

如上所述的解决方案有效。只需要清除缓存(路由中的所有更改始终需要它):

php app/console cache:clear --env=prod
php app/console cache:clear --env=dev