diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index fd01223d794b57d42d9bc178309002425276a2ad..9568d74af38b989542d452cd6e3caf873911c6ab 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -780,12 +780,14 @@ class HTTP * It doesn't matter which one of those cases we have. We just know we can't apply our base URL to the * current URI, so we need to build it back from the PHP environment. */ + $https = self::getServerHTTPS(); $protocol = 'http'; - $protocol .= (self::getServerHTTPS()) ? 's' : ''; + $protocol .= $https ? 's' : ''; $protocol .= '://'; $hostname = self::getServerHost(); $port = self::getServerPort(); + $port = ($https && $port !== ':443') || (!$https && $port !== ':80') ? $port : ''; return $protocol.$hostname.$port.$_SERVER['REQUEST_URI']; }