Welcome Guest, Not a member yet? Register   Sign In
IMG's disappear
#1

[eluser]jedre[/eluser]
Hello,

Firstly, I dont use .htaccess file to remove index.php from URL.
I have problem with my img's.

My CI directory
Code:
index.php
/admin
/css
/js
/gfx
/img
/system
    /cache
    /codeigniter
    /[...]
    /sp <- i change application names
       /config
       /controllers
       /[...]
       /models
       /views

In my config.php file i have base_url set up:
Code:
$config['base_url'] = "http://wolserv.zapto.org/";

In views files i use:
Code:
&lt;link rel="stylesheet" href="css/style.css" type="text/css" /&gt;
<img src="img/sp.gif" />

OK. When I enter on the page with url:
Code:
http://wolserv.zapto.org/

everything is OK, but if I enter with url:
Code:
http://wolserv.zapto.org/index.php/

CSS styles doesn't work and img's doesn't displayed.
If you want, you can visit my page and check it. Click "Wyƛlij" submit button on this page: http://wolserv.zapto.org/

How Can I resolve this problem?
#2

[eluser]gtech[/eluser]
I run a similar directory structure on my localhost ok, is the base_url set in the config.php for a remote host? (only a guess)
Code:
if ($_SERVER['HTTP_HOST'] == 'localhost')
{
    $config['base_url'] = 'http://localhost/codeigniter_install/';
}
else
{

    $config['base_url'] = 'http://ccdev.homelinux.org/codeigniter_install/';
}
#3

[eluser]jedre[/eluser]
http://wolserv.zapto.org is my home server, in config.php i have base_url set up on:
Code:
http://wolserv.zapto.org/
so everything should work but doesn't Sad

Maybe i should use absolute path for my css files and img's? but how can I do it automatically and easy?
#4

[eluser]gtech[/eluser]
normally I tend to put my path in the views as follows

Code:
&lt;link rel="stylesheet" href="&lt;?=base_url()?&gt;css/style.css" /&gt;
<image src="&lt;?=base_url()?&gt;images/del_up.png">
#5

[eluser]Phil Sturgeon[/eluser]
Please search this, it has been answered by myself twice today. You must use absolute paths meaning add base_url() or /images/whatever.gif.

If you use relative filepaths it will be looking for a file in a folder with the name of your controller, which obviously doesnt exist.

Take a look at the asset helper in my sig, that will save you alot of hassle! Smile
#6

[eluser]nirbhab[/eluser]
i use the same gtech uses, when ever i can't find the image, i just add border='1' to it thr u can visualize missing img icon, right click on it and get it info, rest you can change according to it, CI prefers absolute addressing so above mentioned code will surely help you out.




Theme © iAndrew 2016 - Forum software by © MyBB