My navigation bar images and links load fine in CHROME but when loading the same page in INTERNET EXPLORER the images don't load but displays the no image icon. The links in IE are like this
CodeIgniter/index.php/news/index.php/news/
instead of just
CodeIgniter/index.php/news
HOWEVER, IE manages to load the css successfully even though that is also using the base_url()... here is my code:
test.php
<head>
<base href="<?php echo base_url() ?>">
<link rel="stylesheet" type="text/css" href="public/css/main.css">
</head>
<nav>
<ul>
<li><a href="index.php/news">
<img src = "public/images/home.png" alt="Home" title="Home"/>
</a></li>
<li><a href="index.php/news/create">
<img src = "public/images/create.png" alt="Create new article" title="Create new article"/>
</a></li>
</ul>
</nav>
config.php
$config['base_url'] = 'http://localhost/CIgniter/CodeIgniter/';
Quote:Well Fabios suggestion was successful thanks <img src = "<?=base_url('public/images/home.png')?>" alt="Home" title="Home"/>
works even though it is gonna be a pain in future. Thanks for all your help!
Well Fabios suggestion was successful thanks
<img src = "<?=base_url('public/images/home.png')?>" alt="Home" title="Home"/>
works even though it is gonna be a pain in future. Thanks for all your help!
真正的问题是您使用的是相对路径,例如public/images/home.png
而不是/public/images/home.png
,开头的斜杠告诉浏览器它应该根据您拥有的绝对路径来检索内容指定在$config['base_Url'] = ...
而不是当前路径(我是指您到达CodeIgniter/index.php/news
并指定了相对路径,因此才将其附加到它产生错误的路径CodeIgniter/index.php/news
+ index.php/news/
),因此当您在路径的开头添加斜杠时,它将引用绝对路径,并且会在CodeIgniter/index.php/news
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.