Skip to content

Commit

Permalink
MDL-69333 error: Allow explicit http error codes in web server config
Browse files Browse the repository at this point in the history
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
  • Loading branch information
brendanheywood committed Jan 19, 2021
1 parent c381757 commit 5922222
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions error/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
$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();
Expand Down

0 comments on commit 5922222

Please sign in to comment.