MDL-69333 error: Allow explicit http error codes in web server config

eg in Apache you could capture 403 errors and funnel them to this
error handler script and also transform them to 404s:

ErrorDocument 403 /error/index.php?code=404
This commit is contained in:
Brendan Heywood 2020-10-20 16:41:11 +11:00
parent c381757f2a
commit 5922222778

View File

@ -39,6 +39,14 @@ $PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->navbar->add($title);
// This allows the webserver to dictate wether the http status should remain
// what it would have been, or force it to be a 404. Under other conditions
// it could most often be a 403, 405 or a 50x error.
$code = optional_param('code', 0, PARAM_INT);
if ($code == 404) {
header("HTTP/1.0 404 Not Found");
}
$canmessage = has_capability('moodle/site:senderrormessage', $context);
$supportuser = core_user::get_support_user();