我有一个 symfony2 应用程序。
在产品服务器上,我希望所有路由都通过 https 进行,而在开发服务器上,我希望能够使用 http。我如何单独使用 symfony2 来实现这一目标?我不想触及网络服务器配置。
我尝试将其添加到我的routing.yml
myBundle:
resource: "@MyBundle/Controller/"
type: annotation
prefix: /
schemes: [https]
当我有这个的时候routing_dev.yml
:
myBundle:
resource: "@MyBundle/Controller/"
type: annotation
prefix: /
schemes: [http]
_main:
resource: routing.yml
即使在开发模式下它仍然想要转到 https。
您可以为此定义参数。在app/config/config.yml
define:
parameters:
httpProtocol: http
Then in app/config/config_prod.yml
:
parameters:
httpProtocol: https
And in routing.yml
改成:
myBundle:
resource: "@MyBundle/Controller/"
type: annotation
prefix: /
schemes: ['%httpProtocol%']
清除缓存(生产和开发)并且它应该可以工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)