Codeigniter duplicates base_url() Codeigniter duplicates base_url() codeigniter codeigniter

Codeigniter duplicates base_url()


Codeigniter by default will not add the current protocol to your base url, to fix your problem simply update:

$config['base_url'] = 'www.mypage.si/';

to

$config['base_url'] = 'http://www.mypage.si/';

if you want this to be a highly dynamic piece, this is what I currently have as my base url, and it never needs to be updated

$config['base_url'] = "http".((isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS'])) ? "s" : "")."://".$_SERVER['HTTP_HOST']."/";

NOTE:

if you're using an IIS server, this may not produce the same results because the HTTPS element in the $_SERVER global does not get filled the same way.


Change this

$config['base_url'] = 'www.mypage.si/';

to

$config['base_url'] = 'http://www.mypage.si/';

I also want to suggest site_url instead of base_url on view files. For example:

<li><a href="<?php echo site_url('services/cooling'); ?>">cooling</a></li>