[eluser]Jamie Rumbelow[/eluser]
[quote author="ziggyz" date="1257678916"][quote author="Colin Williams" date="1257671252"]For starters, I never include a domain in my base_url setting. I don't know why anyone would.
Code:
$config['base_url'] = '/';
And for database configuration, I like to name the database groups by either the server IP or hostname. Then you can set $active_group to something like $_SERVER['SERVER_ADDR'] or $_SERVER['HOSTNAME'], so it's dynamic in that way.[/quote]
Ingenious! Why haven't I thought of that![/quote]
Actually, a solution I've come up with - not quite as simple as Colin's, but it works - actually guesses the URL correctly based on server variables. This means you can link with URLs, but it's clever enough to guess it and change it dynamically. [url="http://haughin.com"]Haughin[/url] helped me with this one, so props to him.
Code:
$url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$url .= "://".$_SERVER['HTTP_HOST'];
$url .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $url;
I've tested it on a few servers and it hasn't failed for me yet... try it out and let me know if it works for you.
Jamie