Symfony2:从HTTPS路由重定向到HTTP路由

时间:2015-05-21 14:34:01

标签: php symfony routing

我的基本路由"/"http://example.com类似,如果有人呼叫http,我想将此路由重定向到https://example.com。我做错了什么?我是否必须将重定向选项放在其他位置?谢谢!

在我的路由yml中,我有:

my_website:
    resource: "@MyWebsiteBundle/Controller/"
    type:     annotation
    prefix:   /
    defaults:
        route: home //<-- This is my name of the route "/" in my controller
        permanent: true

2 个答案:

答案 0 :(得分:0)

在你的routing.yml:

{{1}}

另一种解决方案,如果您想要所有路由都可以转到security.yml并将access_control参数更改为:

{{1}}

如果您需要https来访问管理员:

{{1}}

可在此处找到更多信息:http://symfony.com/doc/current/book/security.html

答案 1 :(得分:0)

试试这个:

my_website:
    resource: "@MyWebsiteBundle/Controller/"
    type:     annotation
    prefix:   /
    requirements:
        _scheme:  http
相关问题