codeigniter: why is that when i echo base_url() in an href attribute of an anchor tag, it echoes twice
There are three reasons I'm aware about that can cause this.
The first one is when something wrong is written in config.php
on line 17 $config['base_url'] = '';
- it better be left empty, just like when you download CI.
The second one is if you have set $config['base_url']
value to something without prefixing it with http://
or other protocol.
The third one is if you have set base
href
somewhere:
<base href="http://www.mysitedomainname.com/" />
When you need to link to some other page, you should use site_url()
, base_url()
can be used to link stylesheets, js, img src attributes and other real URL's. The reason is pretty simple, base_url()
does not include the index_page
value set in config.php
.
try this
make this
$config['base_url'] = "http://www.mysitedomainname.com"
into this
$config['base_url'] = ""
in config.php
It will work fine if you use
<a href="<?php echo base_url('Controller/Function'); ?>">somelink</a>