From 1c88a2f98709fcaeceea036ba02d3b6fb5404cf2 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 6 Nov 2021 17:07:03 +0100 Subject: [PATCH] The app will now automatically detect the BASE URL based on the current request. --- application/config/config.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/application/config/config.php b/application/config/config.php index c4c78123..c0c81638 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -14,7 +14,18 @@ | path to your installation. | */ -$config['base_url'] = Config::BASE_URL; + +$protocol = + (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') + || (isset($_SERVER['SERVER_PORT']) && (int)$_SERVER['SERVER_PORT'] === 443) + || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') + ? 'https://' : 'http://'; + +$domain = $_SERVER['HTTP_HOST'] ?? 'localhost'; + +$request_uri = dirname($_SERVER['SCRIPT_NAME']); + +$config['base_url'] = $protocol . $domain . $request_uri; /* |--------------------------------------------------------------------------