I am little confuse about root url as people make it by $_server['server_name'] etc.So I just want to know that how to make baseurl in our config php file that work on both server and local side and also how link external file like css,js,images in website.
This will be in your config file.
public function base_url(){
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
return $base_url;
}
In your view you can simply use
echo base_url().'images/abc.jpg';