Firefox检测到服务器正在重定向此地址的请求[…]


Firefox has detected that the server is redirecting the request for this address [...]

我正试图跟进我买的一些教程,通过在Symfony2中做安全,但我得到这个错误。

app/config/security.yml

firewalls:
    # ...
    secured_area:
        pattern: ^/
        form_login:
            check_path: /login_check
            login_path: /login
        logout:
            path: /logout
            target: /
    # disables authentication for assets and the profiler, adapt it according to your needs
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    # ...

/src/SF2/UserBundle/资源/config/routing.yml

UserBundle:
    resource: "@UserBundle/Resources/config/routing/user.yml"
    prefix: /

/src/SF2/UserBundle/资源/config/路由/user.yml

user_login:
    path:     /login
    defaults: { _controller: "UserBundle:Login:login" }
user_login_check:
    path:     /login_check
    defaults: { _controller: "UserBundle:Login:loginCheck" }

以上是我的路由和安全配置。现在,我要显示的表单。

{% extends '::layout.html.twig' %}
{% block title 'Login' %}
{% block body %}
    <div class="container">
        {% if error %}
            <div>
                {{ error.message }}
            </div>
        {% endif %}
        <form action="{{ login_check }}" method="post">
            <label for="username">Username:</label>
            <input type="text" id="username" name="_username" value="{{ last_username }}" class="form-control"/>
            <label for="password">Password:</label>
            <input type="text" id="password" name="_password" class="form-control"/>
            <button type="submit" class="btn btn-primary">Login</button>
        </form>
    </div>
{% endblock %}

loginController中的loginAction与Symfony官网提供的相同,loginCheckAction为空。我按照教程的说明,但我做了一点不同的路线。他使用注释,但我想使用YML文件,因为我发现它更有条理。

当我试图访问/login时发生错误。如果我从from中删除安全配置和{{ login_check }},一切都可以正常工作。

我还能错过什么?

我有办法了。我不得不把anonymous: ~放在secured_area里。谢谢你@malcolm给我看官方文件