CodeIgniter Forums
config['base_url'] for access from public & private network - 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: config['base_url'] for access from public & private network (/showthread.php?tid=13923)



config['base_url'] for access from public & private network - El Forum - 12-11-2008

[eluser]vclef[/eluser]
Hi,

I have an CI-based app that runs on a private IP space (192.168.*.*). This app can also be accessed from the internet (via a hole in the firewall).

My question is: What is the best way to set the config['base_url'] for this app? If I set it to the private IP, obviously it can't be accessed from the internet. If I set it to a public IP, the internal PCs would have to go outside the firewall then come back in. What do you recommend?

Thanks.


config['base_url'] for access from public & private network - El Forum - 12-11-2008

[eluser]attos[/eluser]
To do this you need to remove the protocol and host name from config['base_url'].
If you have:

Code:
config['base_url'] = 'http://hostname/application';

use the following:

Code:
config['base_url'] = '/application';



config['base_url'] for access from public & private network - El Forum - 12-11-2008

[eluser]Phil Sturgeon[/eluser]
The other popular favourite is to use:

Code:
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/application';

attos's approach will be easier if you use a port other than port 80.


config['base_url'] for access from public & private network - El Forum - 12-11-2008

[eluser]vclef[/eluser]
Brilliant!!! Thanks.