There is no such function to retrieve the URL in your way. You need to do it manually. Create a helper called base_helper.php
inside helpers
directory and write this code.
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (!function_exists('url')) {
function url($param = TRUE)
{
if ($param) {
return 'http://site.com/';
}
return 'http://api.site.com/';
}
}
You can call this helpers in controllers/views you wish. Use true
and false
parameter to get main domain or sub domain.
$this->load->helper('base');
echo url();
echo "
";
echo url(false);
Prints
http://site.com/
http://api.site.com/
Hope this helps you. Thanks!!