diff --git a/src/Control/Director.php b/src/Control/Director.php index 2afa4518e82..940697d7ec3 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -556,7 +556,7 @@ public static function host(HTTPRequest $request = null) return $_SERVER['HTTP_HOST']; } - // Check base url + // Check default_base_url if ($baseURL = self::config()->uninherited('default_base_url')) { $baseURL = Injector::inst()->convertServiceProperty($baseURL); $host = static::parseHost($baseURL); @@ -565,6 +565,15 @@ public static function host(HTTPRequest $request = null) } } + // Check base url environment valirable + if ($baseURL = BASE_URL) { + $baseURL = Injector::inst()->convertServiceProperty($baseURL); + $host = static::parseHost($baseURL); + if ($host) { + return $host; + } + } + // Fail over to server_name (least reliable) return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : gethostname(); }