douliao7930 2014-04-07 09:37
浏览 41
已采纳

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

I'would like to redirect a visitor to the Project:index page if he types in www.url.com/project or www.url.com/en/project

Somehow it doesn't find the routes I devined (yes cache was cleared several times)

Here are the routes:

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

And here is the route controller <- this one works normally

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

Here is the error message it get:

No route found for "GET /project/"

Thanks already for your help!

  • 写回答

1条回答 默认 最新

  • dongtang3155 2014-07-20 12:43
    关注

    The solution as described above works. It was only necessary to clear the cache (it's always needed with all changes in routing):

    php app/console cache:clear --env=prod
    
    php app/console cache:clear --env=dev
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?