I have two application for my project
- site.com
- api.site.com
And here’s my config
$config['base_url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/';
If I run site.com, how to get base_url or site_url of api.site.com?
If I run api.site.com, how to get base_url or site_url of site.com?
There is no such function to retrieve the URL in your way. You need to do it manually. Create a helper called
base_helper.phpinsidehelpersdirectory and write this code.You can call this helpers in controllers/views you wish. Use
trueandfalseparameter to get main domain or sub domain.Prints
Hope this helps you. Thanks!!