繁体   English   中英

base_url()在Internet Explorer(CodeIgniter)中无法正常工作

[英]base_url() not working properly in internet explorer (CodeIgniter)

我的导航栏图像和链接在CHROME中可以很好地加载,但是在INTERNET EXPLORER中加载同一页面时,图像不会加载,但会显示no image图标。 IE中的链接是这样的

CodeIgniter / index.php / news / index.php / news /

而不只是

CodeIgniter / index.php / news

但是,即使使用了base_url(),IE仍可以成功加载CSS,这是我的代码:

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建议成功了,谢谢<img src = "<?=base_url('public/images/home.png')?>" alt="Home" title="Home"/>仍然有效未来的痛苦。 感谢你的帮助!

Fabios的建议很成功,谢谢

<img src = "<?=base_url('public/images/home.png')?>" alt="Home" title="Home"/>

即使将来会很痛苦也能正常工作。 感谢你的帮助!

真正的问题是您使用的是相对路径,例如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

暂无
暂无

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

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