问题描述
我认为这里的问题和答案都不应该很复杂.
我已经安装并配置了用于Symfony2的项目中使用的FosuserBundle2.
我需要知道的是在用户尝试访问禁用URL时必须重定向的安全性.
默认情况下它是/登录.但是我想将其更改为更通用/主.
预先感谢
推荐答案
不是由FosuserBundle完成,而是Symfony2中的安全系统.您需要在security.yl中设置以下内容:
firewalls: main: form_login: default_target_path: /path/to/redirect/to
编辑:
对不起,误解了这个问题.将login_path更改为/admin:
firewalls: main: form_login: login_path: /admin
这将您将您重定向到/admin页面 - 确保路径起作用,并且不受防火墙的保护.更多信息在这里..
其他推荐答案
OK
我明白了!
更像:
main: form_login: login_path: /path/to/redirect/to
再次感谢
问题描述
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
推荐答案
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.
其他推荐答案
Ok
I got it!
It was more like:
main: form_login: login_path: /path/to/redirect/to
Thanks again