Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 5 revisions

Don't you just hate it, when you move from development server to production server that you have to change the $config['base_url'] setting?

Well I do. Because I do it a lot, specially when I'm demoing a web application, that's why I added this code to the config.php

[code] $root = "http://".$_SERVER['HTTP_HOST']; $root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['base_url'] = "$root"; [/code]

Once thats added, Codeigniter base_url will adapt to whatever the url your using. But it won't work if CI launchs from cron

Clone this wiki locally