CodeIgniter Automatic Base URL Configuration


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. $config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
  2. $config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
  3. $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.