更改FOSUserBundle(Symfony)中的默认登录页面 [英] Change default Login page in FOSUserBundle (Symfony)
问题描述
我认为这里的问题和答案都不会很复杂.
I think that both the question and the answer here shouldn't be very complicated.
我已经安装并配置了FOSUserBundle以在Symfony2的项目中使用.
I have installed and configured the FOSUserBundle to use in a project with Symfony2.
我需要知道的是,我告诉安全人员在用户尝试访问禁止的URL时必须重定向哪个页面.
What I need to know is where I tell the Security which page it has to redirect the user when they try to access to a forbidden url.
默认情况下是/login.但我想将其更改为更通用的/main.
By default it is /login. But I'd like to change it to a more general /main.
预先感谢
推荐答案
这不是由FOSUserBundle完成,而是由Symfony2中的安全系统完成.您需要在security.yml中设置以下内容:
It's not done by FOSUserBundle, but the Security system in Symfony2. You need to set the following in security.yml:
firewalls:
main:
form_login:
default_target_path: /path/to/redirect/to
对不起,这个问题有误.像这样将login_path更改为/admin:
Sorry, misread the question. Change login_path to /admin like so:
firewalls:
main:
form_login:
login_path: /admin
这会将您重定向到/admin页面-确保路径有效并且不受防火墙保护.更多信息此处.
This will redirect you to the /admin page - make sure the path works and isn't protected by the firewall. More info here.
这篇关于更改FOSUserBundle(Symfony)中的默认登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!