質問

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/';

Answer

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!

他のヒント

The real problem is that you are using relative paths e.g public/images/home.png instead of /public/images/home.png, the slash at the start tells the browser that it should retrieve content based on the absolute path you've specified at $config['base_Url'] = ... instead of the current path it is (I mean you get to CodeIgniter/index.php/news and you've specified a relative path to it so that's why it appened to it producing a wrong path CodeIgniter/index.php/news + index.php/news/) so when you add a slash at the start of your path it will be refering to the absolute path and it will get to you at CodeIgniter/index.php/news.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top