我正在尝试为基于 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/