How to get base url in CodeIgniter

To get the relative address o of your website, you have to first specify base url in application/config/config.php locate the line :

$config['base_url'] = 'localhost/myApp'; // here localhost/myApp is my base url, you can change it to www.example.com

Getting URL in Codeigniter files

echo $this->config->base_url();

and you will get base url as mentioned in config.php file

Share

You may also like...