For security reason codeigniter 3.0.3 or later $config[‘base_url’] must be configure manually.
check this article -> https://www.codeigniter.com/userguide3/installation/upgrade_303.html
When $config['base_url'] is not set, CodeIgniter tries to automatically detect what your website’s base URL is. This is done purely for convenience when you are starting development of a new application.
Auto-detection is never reliable and also has security implications, which is why you should always have it manually configured!
One of the changes in CodeIgniter 3.0.3 is how this auto-detection works, and more specifically it now falls back to the server’s IP address instead of the hostname requested by the client. Therefore, if you’ve ever relied on auto-detection, it will change how your website works now.
But if you still want this work dynamically. you can try this code on \application\config\config.php:
$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']);