Cakephp 1.2.5重定向在控制器中不工作

Cakephp 1.2.5重定向在控制器中不工作,php,cakephp,Php,Cakephp,我在CakePHP1.2.5中有一个应用程序,我正在尝试使用 $this->redirect(array('controller'=>'controller','action'=>'action')); 在重定向之前,我的网站url是,但在重定向之后,它会更改为非ssl,如我如何重定向到ssl 如果有人有任何想法,请帮助我。使用安全组件通常在控制器beforeFilter()中完成。您可以指定所需的安全限制,安全组件将在启动时强制执行这些限制: class AppContro

我在CakePHP1.2.5中有一个应用程序,我正在尝试使用

$this->redirect(array('controller'=>'controller','action'=>'action'));
在重定向之前,我的网站url是,但在重定向之后,它会更改为非ssl,如我如何重定向到ssl


如果有人有任何想法,请帮助我。

使用安全组件通常在控制器beforeFilter()中完成。您可以指定所需的安全限制,安全组件将在启动时强制执行这些限制:

class AppController extends Controller {
    // Add security component
    public $components = array('Security');

    public function beforeFilter() {
        $this->Security->blackHoleCallback = 'forceSSL';
        $this->Security->requireSecure();
    }

    // Add this function in your AppController
    public function forceSSL() {
        return $this->redirect('https://' . env('SERVER_NAME') . $this->here);
    }
}