我偶然发现了一个问题,我无法找到解决方案。
我想将默认的Sonata /admin
网址路径前缀更改为其他内容。
我尝试将routing.yml
路由admin
和_sonata_admin
更改为/admin
以外的其他内容,但仍然是默认的管理面板路径。真的很混乱。
如何更改默认/admin
路径?
更新(routing.yml
列表):
app:
resource: "@AppBundle/Controller/"
type: annotation
sonata_user_profile_show:
resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
sonata_user:
resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
defaults:
_locale: "%locale%"
答案 0 :(得分:3)
要在网址中更改默认管理员前缀,您需要首先在routing.yml
更新,我想通过阅读您已经完成的评论,第二件事需要通过更改管理员在security.yml
中进行更改防火墙模式和access_control
规则,如果需要在应用以下更改后清除缓存
admin_area:
resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
prefix: /panel
_sonata_admin:
resource: .
type: sonata_admin
prefix: /panel
sonata_user:
resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
prefix: /panel
security:
firewalls:
admin:
pattern: /panel(.*)
context: user
form_login:
provider: fos_userbundle
login_path: sonata_user_admin_security_login
use_forward: false
check_path: sonata_user_admin_security_check
failure_path: null
logout:
path: sonata_user_admin_security_logout
target: sonata_user_admin_security_login
anonymous: true
access_control:
# Admin login page needs to be access without credential
- { path: ^/panel/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/panel/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/panel/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/panel/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }