Codeigniter: why does this happen, when I echo base_url () in the href attribute of the anchor tag, it repeats twice

so basically when I repeat the codeigniter base_url () function in the href attribute of the anchor tag, it seems to repeat it twice. Example:

<a href="<?php echo base_url(); ?>">somelink</a>

and above, if you check it, your Chrome browser will display this:

<a href="www.mysitedomainname.com/www.mysitedomainname.com/">somelink</a>

"mysitedomainname.com" is just the name I came up with for this example. Any reason this is happening?

+5
source share
3 answers

There are three reasons that I know about that can cause this.

First, when something is incorrectly written in config.phpline 17 $config['base_url'] = '';, it is better to leave it blank, just like when loading CI.

-, $config['base_url'] - http:// .

, base href -:

<base href="http://www.mysitedomainname.com/" />

- , site_url(), base_url() , js, img src URL. : base_url() index_page, config.php.

+5

,

<a href="<?php echo base_url('Controller/Function'); ?>">somelink</a>
0

try it

do it

$config['base_url'] = "http://www.mysitedomainname.com"

in that

$config['base_url'] = ""

in config.php

0
source

All Articles