Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active September 23, 2015 07:45
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 hissy/7cb3f462f489c118d9fc to your computer and use it in GitHub Desktop.
Save hissy/7cb3f462f489c118d9fc to your computer and use it in GitHub Desktop.
#concrete5 Force SSL(https) in dashboard
<?php
// concrete5.7+
// application/bootstrap/app.php
use Concrete\Core\Http\Request;
use Concrete\Core\Routing\RedirectResponse;
use Concrete\Core\Url\Url;
Events::addListener('on_before_dispatch', function() {
$app = Core::make('app');
$request = Request::getInstance();
if ($request->getScheme() == 'http') {
if (
$request->getPath() == '/login' ||
$request->matches('/login/*') ||
$request->matches('/dashboard/*')
) {
$url = Url::createFromUrl($request->getUri());
$url->setScheme('https');
$response = new RedirectResponse($url);
}
}
if (isset($response)) {
$response->send();
exit;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment