Return to Snippet

Revision: 15616
at July 11, 2009 23:55 by DrewDouglass

Initial Code
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

Initial URL

Initial Description
More info found in the link above, basically, you can replace the $config['base_url'] to the snippet below and you no longer need to set the base url. Useful for making your application more portable.

Initial Title
CodeIgniter Automatic Base URL Configuration

Initial Tags
php, codeigniter

Initial Language