I have developed a cakephp site that should use ssl for all pages. It works as expected except when I use redirect in a controller it redirects to http: //subdomain.domain.c
Its example is already mentioned in the CookBook http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#usage
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);
}
}