使用 Symfony 强制使用 HTTPS

2024-01-21

我试图强制所有对 example.com/checkout/ 的请求使用 HTTPS。我读了Symfony 文档 http://symfony.com/doc/current/cookbook/security/force_https.html并将其放入我的 security.yml 文件中:

access_control:
    - { path: ^/checkout, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }

然而,当我去http://example.com/checkout/ http://example.com/checkout/,我没有被重定向到 HTTPS。我究竟做错了什么?


Yaml:

 secure:
    path:     /secure
    defaults: { _controller: AcmeDemoBundle:Main:secure }
    schemes:  [https]

或注释:

/**
 * @Route("/secure", schemes = "https")
 */
class SecureController
{
     ...
}

更多细节:http://symfony.com/doc/current/cookbook/routing/scheme.html http://symfony.com/doc/current/cookbook/routing/scheme.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Symfony 强制使用 HTTPS 的相关文章

随机推荐