summaryrefslogtreecommitdiffstats
path: root/system/core/Config.php
diff options
context:
space:
mode:
authorvlakoff <vlakoff@gmail.com>2014-04-01 01:21:51 +0200
committervlakoff <vlakoff@gmail.com>2014-04-01 01:22:32 +0200
commitb208f6502917b42a07b4bb7e5ffe2ef4b1359267 (patch)
tree6fa586bdccabc4ada2baa4c3c53cea11ec2f090c /system/core/Config.php
parent8bec33f37bd0e4542d5f963a446283c10a2b2ffe (diff)
Yet another method for determining "base_url"
This one is great because we don't have to deal with the special cases: * in Windows, dirname('/foo/index.php') gives "/foo", but dirname('/index.php') gives "\" instead of "/" * dirname() doesn't include the trailing slash, with the expection of "/" (root) props @narfbg
Diffstat (limited to 'system/core/Config.php')
-rw-r--r--system/core/Config.php9
1 files changed, 1 insertions, 8 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index b2689a6bb..41367d353 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -76,16 +76,9 @@ class CI_Config {
// Set the base_url automatically if none was provided
if (empty($this->config['base_url']))
{
- $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')
- .$script_dir;
+ .substr($_SERVER['SCRIPT_NAME'], 0, -strlen(basename($_SERVER['SCRIPT_NAME'])));
$this->set_item('base_url', $base_url);
}