0
votes

I have a application in cakephp 1.2.5 and i'm try to redirect in another function using

$this->redirect(array('controller'=>'controller','action'=>'action'));

before redirect my website url is https://example.com/controller/action but after redirect its changed to non ssl like http://example.com/controller1/action how can i redirect to ssl

Please help me if any one have any idea.

1

1 Answers

1
votes

Using the security component is generally done in the controllers beforeFilter(). You would specify the security restrictions you want and the Security Component will enforce them on its startup:

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);
    }
}