Change $config['base_url'] with this.
This is one time set config system for all sites and urls.
In application/config folder open config.php
Find this
$config['base_url']='http://example.com';
and replace with this
$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']);