Skip to content

Instantly share code, notes, and snippets.

@chihirokaasan
Last active September 6, 2017 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chihirokaasan/abb3c63ce7c85a01a78cb0f3fa3fb7ab to your computer and use it in GitHub Desktop.
Save chihirokaasan/abb3c63ce7c85a01a78cb0f3fa3fb7ab to your computer and use it in GitHub Desktop.
CakePHP2 CakePHP1.3 redirect to SSL
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