CakePHP2.xでSSL接続(https://)を強制させる
CakePHP利用するのはSecurityコンポーネント。 CakePHPにもともと備わっているコンポーネントなので他所からのDLなどは一切不要です。
コントローラーに数行記述するだけ。
このお手軽さ。まずは、SSL接続を強制したいアクションのあるコントローラーで、Securityコンポーネントの使用を宣言します。
public $components = array('Security');
beforeFilter内に以下の記述を追加します。
ここではif文を使い、アクションがindexの時のみSSL接続が強制されるように設定しています。
コントローラー内の全てのアクションにSSL接続を強制したい時はこのif文は取り払って下さい。
public  function beforeFilter(){
    //indexのみSSL接続を強制
    if ($this->action === 'index') {
        $this->Security->blackHoleCallback = 'forceSSL';
        $this->Security->requireSecure();
    }
}
最後にforceSSLメソッドを追加します。このままコピペでOK。
public function forceSSL() {
    $this->redirect('https://' . env('SERVER_NAME') . $this->here);
}
以上をまとめるとこんな感じ。↓
class HogesController extends AppController {
    public $components = array('Security');
    public  function beforeFilter(){
        //SSLを強制するアクションを設定
        if ($this->action == 'index') { //←アクション名がindexの時だけSSL接続を強制
            $this->Security->blackHoleCallback = 'forceSSL';
            $this->Security->requireSecure();
        }
    }
    public function forceSSL() {
        $this->redirect('https://' . env('SERVER_NAME') . $this->here);
    }
    public function index() {
    }
}
SSLを使わないページにはむしろhttp://を強制したい…という場合
このままだと、https://のページからのリンクは絶対パスで「http://」と指定しない限り全てhttps://になってしまいます。
SSLが必要ないページでSSL接続を解除したい場合は、_unforceSSL()などといったメソッド作ってSSLが不要のアクションにhttps://でアクセスが来た時に実行されるようにします。
以下明滅している部分が、追加したコードです。
class HogesController extends AppController {
    public $components = array('Security');
    public  function beforeFilter(){
        //SSLを強制するアクションを設定
        if ($this->action == 'index') { //←アクション名がindexの時はSSL接続を強制
            $this->Security->blackHoleCallback = 'forceSSL';
            $this->Security->requireSecure();
        }elseif(env('HTTPS')){ //←アクション名がindex以外なのにURLがhttps://だったらhttp://にリダイレクト//+
            $this->_unforceSSL();//+
        }//+
    }
    public function forceSSL() {
        $this->redirect('https://' . env('SERVER_NAME') . $this->here);
    }
    public function _unforceSSL() {//+
        $this->redirect('http://' . env('SERVER_NAME') . $this->here);//+
    }//+
    public function index() {
    }
}
※参考記事はこちら
http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html