diff --git a/src/includes/class/class.LSurl.php b/src/includes/class/class.LSurl.php index 7ba64e82..207d7ee4 100644 --- a/src/includes/class/class.LSurl.php +++ b/src/includes/class/class.LSurl.php @@ -192,13 +192,24 @@ class LSurl extends LSlog_staticLoggerClass { $public_root_url = LSconfig :: get('public_root_url', '/', 'string'); if ($absolute && $public_root_url[0] == '/') { - self :: log_debug("LSurl :: public_root_url(absolute=true): configured public root URL is relative ($public_root_url) => try to detect it from current request infos."); - $public_root_url = 'http'.(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'?'s':'').'://'.$_SERVER['HTTP_HOST'].$public_root_url; - self :: log_debug("LSurl :: public_root_url(absolute=true): detected public absolute root URL: $public_root_url"); + self :: log_debug( + "LSurl :: public_root_url(absolute=true): configured public root URL is relative ". + "($public_root_url) => try to detect it from current request infos." + ); + $public_root_url = sprintf( + "http%s://%s%s", + isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'?'s':'', + $_SERVER['HTTP_HOST'], + $public_root_url + ); + self :: log_debug( + "LSurl :: public_root_url(absolute=true): detected public absolute root URL: ". + $public_root_url + ); } if ($relative_url) { - if ($public_root_url[0] == '/') $public_root_url .= "/"; + if ($public_root_url[-1] != '/') $public_root_url .= "/"; return $public_root_url.$relative_url; }