From 4bdb66759c24c41fefec7952b12a0595a671eaa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 8 Oct 2014 00:29:26 +0300 Subject: Attempt a better base_url auto-detection --- system/core/Config.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/Config.php b/system/core/Config.php index db406dfde..18380a0db 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -78,9 +78,11 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = (is_https() ? 'https' : 'http') - .'://'.$_SERVER['HTTP_HOST'] - .substr($_SERVER['SCRIPT_NAME'], 0, -strlen(basename($_SERVER['SCRIPT_NAME']))); + $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].'/'; + if ( ! empty($_SERVER['DOCUMENT_ROOT'])) + { + $base_url .= ltrim(str_replace('\\', '/', substr(FCPATH, strlen($_SERVER['DOCUMENT_ROOT']))), '/\\'); + } } else { -- cgit v1.2.3-24-g4f1b