Skip to content

Automatic configbase url

World Wide Web Server edited this page Jul 4, 2012 · 7 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 [b]config.php[/b] [code] $config['base_url'] = "http://".$_SERVER['HTTP_HOST']; $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

[/code]

Once thats added, Codeigniter base_url will adapt to whatever the url you're using.

Clone this wiki locally