我正在尝试为基于CakePHP的网站上的某些操作启用SSL.我正在使用requireSecure()并在相应的blackHoleCallback()中重定向到https:// url.
为了减少服务器负载,我想在用户完成需要SSL的操作后重定向回http:// whatever_url.
我该怎么做呢?
所以这是我遇到的一个解决方案.我下面的代码片段加入到beforeFilter()中AppController:
if (!in_array($this->action, $this->Security->requireSecure) and env('HTTPS'))
$this->_unforceSSL();
Run Code Online (Sandbox Code Playgroud)
该功能定义为:
function _unforceSSL() {
$this->redirect('http://' . $_SERVER['SERVER_NAME'] . $this->here);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4137 次 |
| 最近记录: |