CodeIgniter Base URL
When you install the CodeIgniter framework on your server, the base URL and certain other settings are automatically configured on install. These settings are relevant to the server you are installing on. The base url is set to the domain you are installing CodeIgniter on (eg. www.uk-webdeveloper.co.uk) and is called by a method in my class Start extends Controller in this manner:
function Start()
{
parent::Controller();
$this->load->helper('url');
$this->load->library('menu');
$this->load->library('menulower');
$this->load->library('banner');
$this->base = $this->config->item('base_url');
$this->css = $this->config->item('css');
}
As you can see from the method/function shown here, the base_url is located in the config file of your CodeIgniter installation.
Now, as mentioned above, CodeIgniter sets the base_url on install to that of the domain it is installed to. So what happens when you move the whole application to another domain? It may stop functioning.
The Base URL solution
The solution is quite simple.
1. Locate and open your config file (usually at system/application/config/config.php)
2. Find this line:
$config['base_url'] = ‘http://www.yourdomain.co.uk’
3. Replace that line with
$config['base_url'] = ‘http://’.$_SERVER['HTTP_HOST']
4. Save the file.
Now wherever you move the application to, it should still work as expected.
codeigniter base url