diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index dda92a894..25d3a0ecb 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -795,7 +795,21 @@ function sendFile($filename) { /* {{{ */ * @return string */ function getBaseUrl() { /* {{{ */ - return "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST']; + global $settings; + + if(!empty($settings->_baseUrl)) + return $settings->_baseUrl; + + if(isset($_SERVER['X-Forwarded-Host'])) + $host = $_SERVER['X-Forwarded-Host']; + else + $host = $_SERVER['HTTP_HOST']; + if(isset($_SERVER['X-Forwarded-Proto'])) + $ssl = $_SERVER['X-Forwarded-Proto'] == 'https'; + else + $ssl = (isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)); + + return "http".($ssl ? "s" : "")."://".$host; } /* }}} */ function getToken($length){ /* {{{ */