src/Config.php
public function getBaseUrl($include_script_name = false)
	{
		$this->config->load('config');
		$base_url = $this->config->get('base_url');

		if (empty($base_url)) {
			// No base_url defined in the config. Work it out based on server name.
			// This won't work if the app is running behind a proxied URL.
			$protocol = 'http://';

			if (array_key_exists('HTTPS', $_SERVER) && strtolower($_SERVER['HTTPS']) == 'on') {
				$protocol = 'https://';
			}

			$base_url = $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']);
		}

		$base_url = rtrim($base_url, '/') . '/';

		if ($include_script_name) {
			# http://example.com/path/to/app/index.php
			return $base_url . basename($_SERVER['SCRIPT_NAME']);
		} else {
			# http://example.com/path/to/app/
			return $base_url;
		}
	}
public function getBaseUrl($include_script_name = false)
	{
		$this->config->load('config');
		$base_url = $this->config->get('base_url');

		if (empty($base_url)) {
			// No base_url defined in the config. Work it out based on server name.
			// This won't work if the app is running behind a proxied URL.
			$protocol = 'http://';

			if (array_key_exists('HTTPS', $_SERVER) && strtolower($_SERVER['HTTPS']) == 'on') {
				$protocol = 'https://';
			}

			$base_url = $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']);
		}

		$base_url = rtrim($base_url, '/') . '/';

		if ($include_script_name) {
			# http://example.com/path/to/app/index.php
			return $base_url . basename($_SERVER['SCRIPT_NAME']);
		} else {
			# http://example.com/path/to/app/
			return $base_url;
		}
	}
public function getBaseUrl ( $ include_script_name = false ) { $ this -> config -> load ( 'config' ) ; $ base_url = $ this -> config -> get ( 'base_url' ) ; if ( empty ( $ base_url ) ) { // No base_url defined in the config. Work it out based on server name. // This won't work if the app is running behind a proxied URL. $ protocol = 'http://' ; if ( array_key_exists ( 'HTTPS' , $ _SERVER ) && strtolower ( $ _SERVER [ 'HTTPS' ] ) == 'on' ) { $ protocol = 'https://' ; } $ base_url = $ protocol . $ _SERVER [ 'SERVER_NAME' ] . dirname ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; } $ base_url = rtrim ( $ base_url , '/' ) . '/' ; if ( $ include_script_name ) { # http://example.com/path/to/app/index.php return $ base_url . basename ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; } else { # http://example.com/path/to/app/ return $ base_url ; } }
Get the the base url of our app

@param bool $include_script_name Should we include the filename (index.php)?
@return null|string The full URL to our app.
Get the the base url of our app