From d4d414694a77a373a06f141eaece29e675dd0c18 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Wed, 24 May 2017 13:42:34 +0800 Subject: [PATCH] MDL-58318 setuplib: Redirect on https mismatch When the wwwroot indicates https support and a page is accessed over http, redirect to the wwwroot. This is a better experience than displaying an error. --- lib/setuplib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/setuplib.php b/lib/setuplib.php index 9759ced0279..5314dc983ea 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -897,7 +897,11 @@ function initialise_fullme() { // (That is, the Moodle server uses http, with an external box translating everything to https). if (empty($CFG->sslproxy)) { if ($rurl['scheme'] === 'http' and $wwwroot['scheme'] === 'https') { - print_error('sslonlyaccess', 'error'); + if (defined('REQUIRE_CORRECT_ACCESS') && REQUIRE_CORRECT_ACCESS) { + print_error('sslonlyaccess', 'error'); + } else { + redirect($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3); + } } } else { if ($wwwroot['scheme'] !== 'https') {