diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/helpers/url_helper.php | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index d0fab3fe0..36219630d 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -46,13 +46,20 @@ if ( ! function_exists('site_url')) * Create a local URL based on your basepath. Segments can be passed via the * first parameter either as a string or an array. * - * @param string + * @param string $uri + * @param string $protocol * @return string */ function site_url($uri = '') { - $CI =& get_instance(); - return $CI->config->site_url($uri); + $site_url = get_instance()->config->site_url($uri); + + if (isset($protocol)) + { + $site_url = $protocol.substr($site_url, strpos($site_url, '://')); + } + + return $site_url; } } @@ -67,13 +74,20 @@ if ( ! function_exists('base_url')) * Segments can be passed in as a string or an array, same as site_url * or a URL to a file can be passed in, e.g. to an image file. * - * @param string + * @param string $uri + * @param string $protocol * @return string */ - function base_url($uri = '') + function base_url($uri = '', $protocol = NULL) { - $CI =& get_instance(); - return $CI->config->base_url($uri); + $base_url = get_instance()->config->base_url($uri); + + if (isset($protocol)) + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } + + return $base_url; } } |