简体   繁体   English

如何强制symfony2仅对一页使用HTTPS

[英]How to force symfony2 to use HTTPS only for one page

I have to use HTTPS for only single page in symfony2 app. 我必须在symfony2应用程序中仅对单个页面使用HTTPS。 I've tried like 我试过像

security.yml security.yml

- { path: ^/payment, roles: ROLE_USER, requires_channel: https } 

It works good but when i navigate to other pages from /payment page its stays same in HTTPS instead of HTTP. 它工作正常,但是当我从/ payment页面导航到其他页面时,它在HTTPS中而不是HTTP中保持不变。 I've also tried something from sonata admin controller like: 我也尝试过奏鸣曲管理员的一些东西,例如:

PaymentAdmin.php PaymentAdmin.php

$collection
        ->add('makePayment', 'payment/{paymentId}',$options = array('_scheme' => 'https'));

but the same problem.simply i just want to use HTTPS only for /payment page not for other pages.how can i solve this issue. 但是同样的问题。简单地说,我只想仅将HTTPS用于/ payment页面而不用于其他页面。我该如何解决这个问题。

You could try adding regexp start notation "^" to your path like this "^/payment" which should state that routes which start with /payment should be in "https". 您可以尝试将正则表达式开始符号“ ^”添加到路径中,例如“ ^ / payment”,其中应指出以/ payment开头的路由应位于“ https”中。

{ path: ^/payment, roles: ROLE_USER, requires_channel: https } 

The example in http://symfony.com/doc/current/cookbook/security/force_https.html also shows that. http://symfony.com/doc/current/cookbook/security/force_https.html中的示例也显示了这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM