Last active
September 23, 2015 07:45
-
-
Save hissy/7cb3f462f489c118d9fc to your computer and use it in GitHub Desktop.
#concrete5 Force SSL(https) in dashboard
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
<?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