总是被重定向

时间:2013-10-24 12:01:33

标签: php symfony symfony-2.3

使用symfony2.3.​​4。

当我输入地址字段时,我总是会使用以下security.yml和routing.yml重定向:www.example.com/www.example.com/unsecured/startwww.example.com/getlocale我不知道为什么。是否有任何设置access_controls错误?或者是安全性:false / true?

关注security.yml:

firewalls:
dev:
    pattern:  ^/(_(profiler|wdt)|css|images|js)/
    security: false

login:
    pattern:  ^/(en|de)/login
    security: false

secured_area:
    pattern:    ^/
    #anonymous: ~
    http_basic:
        realm: "Secured Area"
    form_login:
        check_path: frontend_account_security_check
        login_path: frontend_account_login
        use_referer:        true
        #default_target_path: frontend_account_my_account
        #target_path_parameter: frontend_account_my_account
    logout: 
        path:   /en/secured/logout
        target: /getlocale
        #anonymous: ~
    #http_basic:
    #    realm: "Secured Demo Area"

access_control:
- { path: ^/en/unsecured/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/de/unsecured/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/en/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/de/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }

我的routing.yml:

frontend_account_login:
  pattern:  /{_locale}/login
  defaults: { _controller: FrontendAccountBundle:Secured:login }
  requirements:
    _locale: en|de

frontend_main_index:
  pattern:  /
  defaults: { _controller: FrontendMainBundle:Main:index }

frontend_main_getlocale:
  pattern:  /getlocale
  defaults: { _controller: FrontendMainBundle:Main:getlocale }

frontend_main_inlocale:
  pattern: /unsecured/start
  defaults: { _controller: FrontendMainBundle:Main:start }

1 个答案:

答案 0 :(得分:1)

哦,废话,我错过了一件小事。正确答案是:

secured_area:
pattern:    ^/
anonymous: ~    //activate the anonymous

access_control:
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/de/secured/, roles: ROLES_USER }