The following lines of code is more smart way to setting up the base_url
in codeigniter:
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
Recommended is
$config['base_url'] = 'https://stackoverflow.com/';
Because everyone knows the hosting space. So if you set like this you can prevent Injection to your site/host.