diff options
author | Andrey Andreev <narf@devilix.net> | 2015-11-09 09:56:30 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2015-11-09 09:58:03 +0100 |
commit | 20edad807645a42df7f4b0baa6e6a2eb29bd2b0c (patch) | |
tree | 71390ac30f5f448cca6570a1a43e23c4d973027c /system/core/Config.php | |
parent | ac66cab946334f76dac699dd67d25225e9b3548c (diff) |
Merge pull request #4217 from natesilva/fix-ipv6-base_url
Build base_url correctly if SERVER_ADDR is IPv6
Diffstat (limited to 'system/core/Config.php')
-rw-r--r-- | system/core/Config.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/system/core/Config.php b/system/core/Config.php index 0264776f9..c507f342c 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -90,7 +90,16 @@ class CI_Config { { if (isset($_SERVER['SERVER_ADDR'])) { - $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['SERVER_ADDR'] + if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE) + { + $server_addr = '['.$_SERVER['SERVER_ADDR'].']'; + } + else + { + $server_addr = $_SERVER['SERVER_ADDR']; + } + + $base_url = (is_https() ? 'https' : 'http').'://'.$server_addr .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); } else |