CodeIgniter Forums
Dynamic Base URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Dynamic Base URL (/showthread.php?tid=57951)



Dynamic Base URL - El Forum - 04-29-2013

[eluser]Tejas D[/eluser]
Hello....


I developed a website using CodeIgniter.
I configure base url as below (for eg):
Code:
$config['base_url'] = 'http://abc.pqr.net/';

Till now website is working fine.

My question is can I set the above base url parameter dynamically depending on user type the address in browser.

eg:
if in browser user type
Code:
http://xyz.abc.net/
then I want to set this to base url in config file.





Dynamic Base URL - El Forum - 04-29-2013

[eluser]rana[/eluser]
Which version of codeigniter are you using? Use the latest version and keep this field empty:
Code:
$config['base_url'] = '';
The latest version is pretty intelligent to detect the base_url itself and it will do your work fine. Thanks.