Author: Jordi Kroon (jordikroon)
Committer: Derick Rethans (derickr)
Date: 2026-06-16T11:51:50+01:00

Commit: 
https://github.com/php/web-php/commit/88dc15b8ba0da15da6394aba6c0207fd4cdf63ec
Raw diff: 
https://github.com/php/web-php/commit/88dc15b8ba0da15da6394aba6c0207fd4cdf63ec.diff

use HTTP_HOST instead of SERVER_NAME

Changed paths:
  M  include/site.inc


Diff:

diff --git a/include/site.inc b/include/site.inc
index aae24537a6..2f48c491ea 100644
--- a/include/site.inc
+++ b/include/site.inc
@@ -233,24 +233,14 @@ function get_shortname($page) {
     return $shorturl;
 }
 
-// Guess the current site from what Apache tells us.
-// This should be the main name of the mirror (in case
-// it works under more then one name). SERVER_NAME is
-// the name of the Apache vhost.
-
-if (!isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on") {
-    $proto = "http";
-} else {
-    $proto = "https";
-}
+// Build the base URL for the current site using the
+// request scheme (HTTP/HTTPS) and the Host header.
 
-if ($_SERVER["SERVER_PORT"] != '80' && $_SERVER["SERVER_PORT"] != 443) {
-    $MYSITE = $proto . '://' . $_SERVER["SERVER_NAME"] . ':' . 
(int)$_SERVER["SERVER_PORT"] . '/';
-    $msite = 'http://' . $_SERVER["SERVER_NAME"] . ':' . 
(int)$_SERVER["SERVER_PORT"] . '/';
-} else {
-    $MYSITE = $proto . '://' . $_SERVER["SERVER_NAME"] . '/';
-    $msite = 'https://' . $_SERVER["SERVER_NAME"] . '/';
-}
+$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
+    ? 'https'
+    : 'http';
+
+$MYSITE = $scheme . '://' . $_SERVER['HTTP_HOST'] . '/';
 
 // If the mirror is not registered with this name, provide defaults
 // (no country code, no search, no stats, English default language ...)

Reply via email to