How to force https for prod but http for dev environment?

后端 未结 4 1395
孤街浪徒
孤街浪徒 2021-02-02 11:13

I have a symfony2 application.

On the prod server I want all my routes to go via https, while in dev I want to be able to use http. How do I achieve that with symfony2 a

4条回答
  •  后悔当初
    2021-02-02 11:15

    You can define parameter for that. In app/config/config.yml define:

    parameters:
        httpProtocol: http
    

    Then in app/config/config_prod.yml:

    parameters:
        httpProtocol: https
    

    And in routing.yml change to:

    myBundle:
        resource: "@MyBundle/Controller/"
        type:     annotation
        prefix:   /
        schemes:  ['%httpProtocol%']
    

    Clear the cache (both prod and dev) and it should work.

提交回复
热议问题