diff options
-rw-r--r-- | system/core/Config.php | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/system/core/Config.php b/system/core/Config.php index 56259bd06..728e28dd8 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,9 +76,11 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { + $script_basename = basename($_SERVER['SCRIPT_NAME']); + $base_url = (is_https() ? 'https' : 'http') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') - . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + . preg_replace('/'.preg_quote($script_basename).'$/', '', $_SERVER['SCRIPT_NAME']); $this->set_item('base_url', $base_url); } |