简体   繁体   中英

Symfony 2.6 restrict url by host but allow a specific IP to access it

I am trying to allow a specific IP to access a restricted path defined in security.yml with no success.

I have these 2 lines in my security.yml:

access_control:
        - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY,  ip: "127.0.0.1" }
        - { path: ^/.*, role: IS_AUTHENTICATED_FULLY, host: "test.loc" }

However, I am redirected to the login page when I try to access the project on my local.

How can I achieve it?

My guess is that you're running afoul of Chrome's aggressive 301 redirect caching. See a discussion here . Try in another browser such as Firefox.

The problem should go away if you clear Chrome's browsing data. You can also pop in to incognito mode to test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM