0

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 Answer 1

1

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);
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.