【问题标题】:Redirect from /profile to /profile/edit [FOSUserBundle]从 /profile 重定向到 /profile/edit [FOSUserBundle]
【发布时间】:2014-09-15 13:38:41
【问题描述】:

我想将人们从 /profile 重定向到 /profile/edit,我在 routing.yml 中尝试这样做:

another_route:
    path: /profile
    defaults:
        _controller: FOSUserBundle:Profile:edit
        route: fos_user_profile_edit
        permanent: true

但是,这行不通(它仍然会通过该站点的内容进入 /profile 页面)。从我在 Symfony 页面上读到的内容来看,它应该可以工作..

【问题讨论】:

    标签: php symfony redirect


    【解决方案1】:

    如果您在 custom 路由规则之前导入 FOSUserBundle 路由,您的重定向将不起作用,当然,路由随后匹配并且在第一次匹配时停止解析。

    你的another_route 也有问题:即使你移动它 - 没有任何修改 - 这也不起作用,因为你传递了错误的控制器值

    所以你必须修改_controller 的值(如下)并将该路由放在FOSUserBundle import 个之前

    another_route:
        path: /profile
        defaults:
            _controller: FrameworkBundle:Redirect:redirect
            route: fos_user_profile_edit
            permanent: true
    

    【讨论】:

      猜你喜欢
      • 2019-01-06
      • 1970-01-01
      • 2019-05-22
      • 2021-12-23
      • 2017-05-16
      • 1970-01-01
      • 2013-10-22
      • 2013-09-19
      • 1970-01-01
      相关资源
      最近更新 更多