Base URL Question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Base URL Question (/showthread.php?tid=4877) |
Base URL Question - El Forum - 12-20-2007 [eluser]Unknown[/eluser] Just a quick one for the guru's out there. I have been playing with code igniter for a couple months. My app (a robust, very simply CMS) will be running around 300 individual sites that correspond to around 500 domains.. Now the easy way around the setting base_url that I came up with initially was to simply use: $config['base_url'] = 'http://'.$_SERVER['HTTP_HOST']; Now I am getting to the stage of writing developer documentation etc I am trying to work out why this seems too easy or something. Can someone tell me why I shouldnt be doing it like this and what would be a more "elegant" solution.. if not can someone tell me why this isn't set like this as default..?/ Base URL Question - El Forum - 12-20-2007 [eluser]ejangi[/eluser] Well... you're probably not taking into account that some people (highly unlikely, but possible none the less) might run the site securely (i.e. https://) and/or from a certain port (i.e. http://www.mysite.com:2082/), so maybe you could do: Code: $config['base_url'] = ((!$_SERVER['HTTPS'] || $_SERVER['HTTPS'] == 'off') ? 'http' : 'https').'://'.$_SERVER['HTTP_HOST'].(($_SERVER['REMOTE_PORT']) ? ':'.$_SERVER['REMOTE_PORT'] : '').'/'; Now, that's what I call inelegant! |