Skip to content

Instantly share code, notes, and snippets.

@imAjaypal
Last active March 18, 2022 08:03
Show Gist options
  • Save imAjaypal/bbcaf94a5b52395e6215f26f4157edef to your computer and use it in GitHub Desktop.
Save imAjaypal/bbcaf94a5b52395e6215f26f4157edef to your computer and use it in GitHub Desktop.
Dynamic Base URL (base_url) in Codeigniter
//Dynamic Base URL (base_url) in Codeigniter
$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']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment