Thursday, January 21, 2010

CodeIgniter - Automatic config base url

In CodeIgniter, you may know that you need to configure base url via config.php (param: $config["base_url"]) so when change domain you may doubt sometimes with such small error; Here a solution to help solving the issue;

Change at config.php by fix url with this smart url configuration:

$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']);

Source: http://codeigniter.com/wiki/Automatic_configbase_url/

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.