Skip to content

Commit 88dc15b

Browse files
jordikroonderickr
authored andcommitted
use HTTP_HOST instead of SERVER_NAME
1 parent 86f16e3 commit 88dc15b

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

include/site.inc

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,14 @@ function get_shortname($page) {
233233
return $shorturl;
234234
}
235235

236-
// Guess the current site from what Apache tells us.
237-
// This should be the main name of the mirror (in case
238-
// it works under more then one name). SERVER_NAME is
239-
// the name of the Apache vhost.
240-
241-
if (!isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on") {
242-
$proto = "http";
243-
} else {
244-
$proto = "https";
245-
}
236+
// Build the base URL for the current site using the
237+
// request scheme (HTTP/HTTPS) and the Host header.
246238

247-
if ($_SERVER["SERVER_PORT"] != '80' && $_SERVER["SERVER_PORT"] != 443) {
248-
$MYSITE = $proto . '://' . $_SERVER["SERVER_NAME"] . ':' . (int)$_SERVER["SERVER_PORT"] . '/';
249-
$msite = 'http://' . $_SERVER["SERVER_NAME"] . ':' . (int)$_SERVER["SERVER_PORT"] . '/';
250-
} else {
251-
$MYSITE = $proto . '://' . $_SERVER["SERVER_NAME"] . '/';
252-
$msite = 'https://' . $_SERVER["SERVER_NAME"] . '/';
253-
}
239+
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
240+
? 'https'
241+
: 'http';
242+
243+
$MYSITE = $scheme . '://' . $_SERVER['HTTP_HOST'] . '/';
254244

255245
// If the mirror is not registered with this name, provide defaults
256246
// (no country code, no search, no stats, English default language ...)

0 commit comments

Comments
 (0)