diff --git a/lib/weblib.php b/lib/weblib.php index 3155662b11c..e8cdff75e6e 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -124,7 +124,15 @@ function me() { function qualified_me() { /// like me() but returns a full URL - if (!empty($_SERVER["HTTP_HOST"])) { + global $CFG; + + if (!empty($CFG->wwwroot)) { + $url = parse_url($CFG->wwwroot); + } + + if (!empty($url['host'])) { + $hostname = $url['host']; + } else if (!empty($_SERVER["HTTP_HOST"])) { $hostname = $_SERVER["HTTP_HOST"]; } else if (!empty($_ENV["HTTP_HOST"])) { $hostname = $_ENV["HTTP_HOST"];