Two base_url possible? |
[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/;}
[eluser]smith[/eluser]
used to do this: Code: if ($_SERVER['SERVER_NAME']=='something')
[eluser]bjora857[/eluser]
it worked excellent. $_SERVER['SERVER_NAME']=='something' was just what I was looking for. thanks
[eluser]blackarma[/eluser]
Another solution : Put the hostname in a environment variable and load it directly.
[eluser]Michael Wales[/eluser]
Code: $config['base_url'] = "http://".$_SERVER['HTTP_HOST']; or Code: $proto = "http" . From: this thread
[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
[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
[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?
[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 |
Welcome Guest, Not a member yet? Register Sign In |