Last active
September 6, 2017 02:02
-
-
Save chihirokaasan/abb3c63ce7c85a01a78cb0f3fa3fb7ab to your computer and use it in GitHub Desktop.
CakePHP2 CakePHP1.3 redirect to SSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppController extends Controller | |
{ | |
var $components = array('Security'); | |
function beforeFilter() | |
{ | |
// When you want to specify the action | |
/* | |
*if ($this->action === 'index') { | |
* $this->Security->blackHoleCallback = 'forceSSL'; | |
* $this->Security->requireSecure(); | |
}*/ | |
$this->Security->blackHoleCallback = 'forceSSL'; | |
$this->Security->requireSecure(); | |
} | |
public function forceSSL() { | |
$this->redirect('https://' . env('SERVER_NAME') . $this->here); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment