summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlakoff <vlakoff@gmail.com>2014-03-31 20:46:04 +0200
committervlakoff <vlakoff@gmail.com>2014-03-31 20:46:04 +0200
commit2516f3b3945106aeebda87bd6a35454b7d72bdba (patch)
tree08621df73c414923a287c585f10a82b801825da6
parentdfd51cb0379936a5cc90b980ddf46b170f3b365b (diff)
Robuster determination of "base_url" config item
Remove the basename only at the end, to avoid edge cases.
-rw-r--r--system/core/Config.php4
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);
}