cakephp - 有选择地为 CakePHP 中的某些操作启用 SSL

标签 cakephp ssl https

我正在尝试为基于 CakePHP 的网站上的某些操作启用 SSL。我正在使用 requireSecure() 执行此操作并重定向到 https://url在相应的 blackHoleCallback() 中。

为了降低服务器负载,我想重定向回 http://whatever_url一旦用户完成需要 SSL 的操作。

我该怎么做?

最佳答案

所以这是我想到的一个解决方案。我将以下代码片段添加到 AppController 中的 beforeFilter():

if (!in_array($this->action, $this->Security->requireSecure) and env('HTTPS'))
    $this->_unforceSSL();

函数定义为:

function _unforceSSL() {
    $this->redirect('http://' . $_SERVER['SERVER_NAME'] . $this->here);
}

关于cakephp - 有选择地为 CakePHP 中的某些操作启用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/751338/

相关文章:

javascript - 动态更改浏览器 http 代理设置

url - https URL 重定向到外部站点

php - 当我尝试 CakePHP 方式时,Cakephp 2.8.x 查询访问冲突。正常查询有效

mysql - Cakephp用户管理插件创建表

spring - 将 SSL 与 Redis 和 Spring Data Redis 一起使用时为 "Cannot get Jedis connection"

bash - 使用 https 将 bash curl 到同一台服务器

java - Apache http 客户端 : Received fatal alert: bad_certificate

authentication - CakePHP 3.2 : Prevent authError showing when user is not logged in

cakephp 让用户向模型添加自定义字段

Git 客户端和服务器在同一台机器上