问题
I think that both the question and the answer here shouldn't be very complicated.
I have installed and configured the FOSUserBundle to use in a project with Symfony2.
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.
By default it is /login. But I'd like to change it to a more general /main.
Thanks in advance
回答1:
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
EDIT:
Sorry, misread the question. Change login_path to /admin like so:
firewalls:
main:
form_login:
login_path: /admin
This will redirect you to the /admin page - make sure the path works and isn't protected by the firewall. More info here.
回答2:
Ok
I got it!
It was more like:
main:
form_login:
login_path: /path/to/redirect/to
Thanks again
来源:https://stackoverflow.com/questions/11819547/change-default-login-page-in-fosuserbundle-symfony