Question

I use the base url in code igniter like this:

<a href="<?=base_url()?>../../includes/images/logo_fosss.png">

The above code runs correctly.

But sometimes this code gives an error, and the code must be changed like this:

<a href="<?=base_url()?>../../../includes/images/logo_fosss.png">

I've put a folder 'includes' in the root (same place level as application and system).

What's wrong with my code?

Était-ce utile?

La solution

base_url() should be used for absolute URLs.

If you include ../ you are stating that the URL is relative.

I think your code should be something like this:

<a href="<?=base_url()?>includes/images/logo_fosss.png">

or like this:

<a href="<?=base_url()?>/includes/images/logo_fosss.png">

Make sure your includes folder is in the root folder of your Codeigniter install.

For more information, check out this article:

http://www.webdevelopersnotes.com/design/relative_and_absolute_urls.php3

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top