![]() |
Two base_url possible? - 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: Two base_url possible? (/showthread.php?tid=3579) |
Two base_url possible? - El Forum - 10-11-2007 [eluser]bjora857[/eluser] When I code I use a local webserver. And when Im happy with my code I upload it to my web host. Nothing strange with that... But every time I upload I have to change the commenting in my config file. $config['base_url'] = "http://localhost:8888/"; //$config['base_url'] = "http://www.mydomain.com/"; Is there a better way? something like this psuedo code if (isValid(http://localhost:8888/)) {$config['base_url'] = "http://localhost:8888/";} else {$config['base_url'] = "http://www.mydomain.com/;} Two base_url possible? - El Forum - 10-11-2007 [eluser]smith[/eluser] used to do this: Code: if ($_SERVER['SERVER_NAME']=='something') Two base_url possible? - El Forum - 10-11-2007 [eluser]bjora857[/eluser] it worked excellent. $_SERVER['SERVER_NAME']=='something' was just what I was looking for. thanks Two base_url possible? - El Forum - 10-11-2007 [eluser]blackarma[/eluser] Another solution : Put the hostname in a environment variable and load it directly. Two base_url possible? - El Forum - 10-11-2007 [eluser]Michael Wales[/eluser] Code: $config['base_url'] = "http://".$_SERVER['HTTP_HOST']; or Code: $proto = "http" . From: this thread Two base_url possible? - El Forum - 10-25-2007 [eluser]mgnsrsn[/eluser] Hi, do I really need to have the site ip/name in the base_url? Cant I just specify the path. I.e. if I have http://server/code/ , cant I just set $config['base_url'] = "/code/" ? This would allow for unlimited sites (as long as the path is the same...) Thanks Two base_url possible? - El Forum - 10-25-2007 [eluser]xwero[/eluser] [quote author="mgnsrsn" date="1193336363"]Hi, do I really need to have the site ip/name in the base_url? Cant I just specify the path. I.e. if I have http://server/code/ , cant I just set $config['base_url'] = "/code/" ? This would allow for unlimited sites (as long as the path is the same...) Thanks[/quote] You could try to put it in the index_page $config['index_page'] = "code/index.php"; But i'm not sure it will work Two base_url possible? - El Forum - 10-25-2007 [eluser]mgnsrsn[/eluser] My problem is that Im using base_url in all img, js, css links etc. And its also used in the form_open function by CI. E.g. <img src="<?=base_url()?>images/projectIcons/logo.gif" alt=""> <?=form_open('app/login', array('name' => 'loginform', 'id' => 'loginform'))?> If I have multiple sites, or multiple networks to my site, I cant have a specific ip address/name configured in the base_url. Therefor I thought that I could leave the ip address/name out. It seems to work, but I wonder if I cause problems somewhere else in CI. Any thoughts? Two base_url possible? - El Forum - 10-25-2007 [eluser]John_Betong[/eluser] There are numerous solutions to the different paths problem between http://localhost and the online version. The way I do it is to have this define in my index.php and change the paths wherever required. Code: // index.php |