summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorvlakoff <vlakoff@gmail.com>2014-03-31 20:46:14 +0200
committervlakoff <vlakoff@gmail.com>2014-03-31 20:46:14 +0200
commit93836ff351e3035bf368ed56da09ac27e354989f (patch)
treef5430d5fd1181ba7212d8f1d8be0d8749bfe164d /system
parent2516f3b3945106aeebda87bd6a35454b7d72bdba (diff)
Different method for determining "base_url"
Better performance by not using regex.
Diffstat (limited to 'system')
-rw-r--r--system/core/Config.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index 728e28dd8..ec852b133 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -76,11 +76,16 @@ class CI_Config {
// Set the base_url automatically if none was provided
if (empty($this->config['base_url']))
{
- $script_basename = basename($_SERVER['SCRIPT_NAME']);
+ $script_dir = strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/');
+
+ if ($script_dir !== '/')
+ {
+ $script_dir .= '/';
+ }
$base_url = (is_https() ? 'https' : 'http') . '://'
. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost')
- . preg_replace('/'.preg_quote($script_basename).'$/', '', $_SERVER['SCRIPT_NAME']);
+ . $script_dir;
$this->set_item('base_url', $base_url);
}