Base URL Question |
[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..?/
[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! |
Welcome Guest, Not a member yet? Register Sign In |