[英]Redirect from /profile to /profile/edit [FOSUserBundle]
我想將人們從/ profile重定向到/ profile / edit,我在routing.yml中嘗試這樣做:
another_route:
path: /profile
defaults:
_controller: FOSUserBundle:Profile:edit
route: fos_user_profile_edit
permanent: true
但是,這不起作用(它仍然可以通過此站點的內容進入/ profile頁面)。 從我在Symfony的頁面上看到它應該工作..
如果您在自定義路由規則之前導入FOSUserBundle
路由,那么您的重定向將不起作用,當然,隨后會匹配路由並在首次匹配時停止解析。
你的another_route
也有問題:即使你移動它 - 沒有任何修改 - 這將無效,因為你傳遞了錯誤的控制器值
因此,您必須修改_controller
值(如下所示)並在FOSUserBundle
導入之前放置該路由
another_route:
path: /profile
defaults:
_controller: FrameworkBundle:Redirect:redirect
route: fos_user_profile_edit
permanent: true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.