diff --git a/libraries/joomla/application/web.php b/libraries/joomla/application/web.php index 14d7122d67bcc..a5256c2c73996 100644 --- a/libraries/joomla/application/web.php +++ b/libraries/joomla/application/web.php @@ -848,6 +848,9 @@ protected function detectRequestUri() $scheme = 'http://'; } + // Try to acquire the server host, if set. + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; + /* * There are some differences in the way that Apache and IIS populate server environment variables. To * properly detect the requested URI we need to adjust our algorithm based on whether or not we are getting @@ -860,13 +863,13 @@ protected function detectRequestUri() if (!empty($_SERVER['PHP_SELF']) && !empty($_SERVER['REQUEST_URI'])) { // The URI is built from the HTTP_HOST and REQUEST_URI environment variables in an Apache environment. - $uri = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + $uri = $scheme . $host . $_SERVER['REQUEST_URI']; } // If not in "Apache Mode" we will assume that we are in an IIS environment and proceed. elseif (isset($_SERVER['HTTP_HOST'])) { // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS - $uri = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; + $uri = $scheme . $host . $_SERVER['SCRIPT_NAME']; // If the QUERY_STRING variable exists append it to the URI string. if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) diff --git a/libraries/joomla/uri/uri.php b/libraries/joomla/uri/uri.php index e19f815c45b6a..a61ece0a5c573 100644 --- a/libraries/joomla/uri/uri.php +++ b/libraries/joomla/uri/uri.php @@ -72,6 +72,9 @@ public static function getInstance($uri = 'SERVER') $https = '://'; } + // Try to acquire the server host, if set. + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; + /* * Since we are assigning the URI from the server variables, we first need * to determine if we are running on apache or IIS. If PHP_SELF and REQUEST_URI @@ -82,7 +85,7 @@ public static function getInstance($uri = 'SERVER') { // To build the entire URI we need to prepend the protocol, and the http host // to the URI string. - $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + $theURI = 'http' . $https . $host . $_SERVER['REQUEST_URI']; } else { @@ -93,7 +96,7 @@ public static function getInstance($uri = 'SERVER') * * IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS */ - $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; + $theURI = 'http' . $https . $host . $_SERVER['SCRIPT_NAME']; // If the query string exists append it to the URI string if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) diff --git a/modules/mod_wrapper/helper.php b/modules/mod_wrapper/helper.php index 5afd93f63e8ce..09db71fbea106 100644 --- a/modules/mod_wrapper/helper.php +++ b/modules/mod_wrapper/helper.php @@ -44,8 +44,9 @@ public static function getParams(&$params) // Adds 'http://' if none is set if (substr($url, 0, 1) == '/') { - // Relative url in component. use server http_host. - $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; + // Relative url in component. use server http_host, if set. + $host = JFactory::getApplication()->input->server->getString('HTTP_HOST'); + $url = 'http://' . $host . $url; } elseif (!strstr($url, 'http') && !strstr($url, 'https')) {