Skip to content

Commit 2516f3b

Browse files
committed
Robuster determination of "base_url" config item
Remove the basename only at the end, to avoid edge cases.
1 parent dfd51cb commit 2516f3b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

system/core/Config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ public function __construct()
7676
// Set the base_url automatically if none was provided
7777
if (empty($this->config['base_url']))
7878
{
79+
$script_basename = basename($_SERVER['SCRIPT_NAME']);
80+
7981
$base_url = (is_https() ? 'https' : 'http') . '://'
8082
. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost')
81-
. str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
83+
. preg_replace('/'.preg_quote($script_basename).'$/', '', $_SERVER['SCRIPT_NAME']);
8284

8385
$this->set_item('base_url', $base_url);
8486
}

0 commit comments

Comments
 (0)