我使用的是FOSUserBundle,我只是想用'/ account'作爲其所有路由的前綴。 我有一個UserBundle從FOSUserBundle繼承:Symfony3.3重定向到路由不採用定義的路徑
<?php
//UserBundle.php
namespace UserBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class UserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
定義該控制器在我的路線前綴:
# app/config/routing.yml
user:
resource: "@UserBundle/Resources/config/routing.yml"
prefix: /account
和進口FOS路線在我的包:
#UserBundle/config/routing.yml
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
prefix: /user
我試着通過文件覆蓋文件,以及所有的路由,通過XML(覆蓋父文件)或通過yml。我總是路線明確的(BIN /控制檯調試輸出:路線--show控制器):
fos_user_security_login GET|POST ANY ANY /account/login FOSUserBundle:Security:login
fos_user_security_check POST ANY ANY /account/login_check FOSUserBundle:Security:check
fos_user_security_logout GET|POST ANY ANY /account/logout FOSUserBundle:Security:logout
fos_user_profile_show GET ANY ANY /account/profile/ FOSUserBundle:Profile:show
fos_user_profile_edit GET|POST ANY ANY /account/profile/edit FOSUserBundle:Profile:edit
fos_user_registration_register GET|POST ANY ANY /account/register/ FOSUserBundle:Registration:register
fos_user_registration_check_email GET ANY ANY /account/register/check-email FOSUserBundle:Registration:checkEmail
fos_user_registration_confirm GET ANY ANY /account/register/confirm/{token} FOSUserBundle:Registration:confirm
fos_user_registration_confirmed GET ANY ANY /account/register/confirmed FOSUserBundle:Registration:confirmed
fos_user_resetting_request GET ANY ANY /account/resetting/request FOSUserBundle:Resetting:request
fos_user_resetting_send_email POST ANY ANY /account/resetting/send-email FOSUserBundle:Resetting:sendEmail
fos_user_resetting_check_email GET ANY ANY /account/resetting/check-email FOSUserBundle:Resetting:checkEmail
fos_user_resetting_reset GET|POST ANY ANY /account/resetting/reset/{token} FOSUserBundle:Resetting:reset
fos_user_change_password GET|POST ANY ANY /account/profile/change-password FOSUserBundle:ChangePassword:changePassword
但是,當我重定向到「fos_user_security_login」我重定向到「/登錄」,而不是路線「/帳號/登錄」
如果你有任何想法,爲什麼,我會請了解:對 編輯:這裏是在security.yml防火牆和ACL
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
check_path: /account/login_check
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
# if you are using Symfony < 2.8, use the following config instead:
# csrf_provider: form.csrf_provider
logout:
path: /account/logout
target: /account/login
anonymous: true
access_control:
# authorise to login and reset password for everyone
- { path: ^/account, role: IS_AUTHENTICATED_ANONYMOUSLY }
顯示您的security.yml –
在帖子結尾添加它;) – Thiryn
模板覆蓋工作,但似乎控制器覆蓋不起作用 – Thiryn