简体   繁体   English

base_url codeigniter 解决方案

[英]base_url codeigniter solution

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).我在根目录中放置了一个文件夹“includes”(与应用程序和系统位于同一位置)。

What's wrong with my code?我的代码有什么问题?

base_url() should be used for absolute URLs. base_url()应该用于绝对URL。

If you include ../ you are stating that the URL is relative .如果包含../ ,则表示该 URL 是相对的

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.确保您的包含文件夹位于您的 Codeigniter 安装的根文件夹中。

For more information, check out this article:有关更多信息,请查看这篇文章:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM