Symfony 2:为所有路由强制使用 https
Symfony 2: Force https for all routes
我在symfony 2 框架中做了一个web 应用程序。
这工作正常,但现在我想将所有路由的 http:// 更改为 https://!
以及如何检查我的环境是否是本地主机。如果我在本地工作,我想使用普通的 http://.
在哪里设置,我找不到?
谢谢!
给你:
(未测试但应该可以。)
# app/config/security.yml
security:
# ...
access_control:
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https, host: yourdomain\.com$ }
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: http, host: localhost$ }
http://symfony.com/doc/current/cookbook/security/access_control.html#forcing-a-channel-http-https
我在symfony 2 框架中做了一个web 应用程序。 这工作正常,但现在我想将所有路由的 http:// 更改为 https://!
以及如何检查我的环境是否是本地主机。如果我在本地工作,我想使用普通的 http://.
在哪里设置,我找不到?
谢谢!
给你: (未测试但应该可以。)
# app/config/security.yml
security:
# ...
access_control:
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https, host: yourdomain\.com$ }
- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: http, host: localhost$ }
http://symfony.com/doc/current/cookbook/security/access_control.html#forcing-a-channel-http-https