diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 5dfd4d05172a01b1ac054cc51afb73a8fc94caaa..2e823a24a3d6659cea2e84b4eeedcebc160a4e91 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -15,7 +15,15 @@ class SimpleSAML_Utilities { */ public static function getSelfHost() { - $currenthost = $_SERVER['HTTP_HOST']; + if (array_key_exists('HTTP_HOST', $_SERVER)) { + $currenthost = $_SERVER['HTTP_HOST']; + } elseif (array_key_exists('SERVER_NAME', $_SERVER)) { + $currenthost = $_SERVER['SERVER_NAME']; + } else { + /* Almost certainly not what you want, but ... */ + $currenthost = 'localhost'; + } + if(strstr($currenthost, ":")) { $currenthostdecomposed = explode(":", $currenthost); $currenthost = $currenthostdecomposed[0];