CodeIgniter Forums
Images & css not loaded - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Images & css not loaded (/showthread.php?tid=15820)



Images & css not loaded - El Forum - 02-16-2009

[eluser]Exolead[/eluser]
Hi ,
Please excuse my English, I’m not good at writing.
Like some people in this forum, I have a problem with loading images and css into my views. I tried all solutions but I’m still having the same issue.
The home page is loaded correctly if I use the simplified URL http://localhost/mysite or even http://localhost/mysite/index.php. But I get a problem with this url : http://localhost/ares/index.php/home, images and css don’t load.
The main problem is that when I call this page : http://localhost/mysite/home/topic/1, images and css don’t work at all. Please, help me!!


My .htaccess file :
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|styles|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

config file:
$config['base_url'] = "http://localhost/mysite";
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
$config['rewrite_short_tags'] = TRUE;

routes.php:
$route['default_controller'] = "home";

in my httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so

<Directory "${path}/www">
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>

These are my directories:
-www
----mysite
----------images
----------styles
----------system
----------------application
---------------------------controllers
--------------------------------------home.php
---------------------------views
--------------------------------------home_view.php
--------------------------------------topic_view.php
---------------------------models
--------------------------------------home_model.php
--------------------------------------topic_model.php
--------------------------------------....
---------------------------....
----------.htaccess
----------favicon.ico
----------index.php


Exemple of inserting images & the css file

&lt;link href="styles/main.css" rel="stylesheet" type="text/css" /&gt;

<img src="images/logo.jpg" alt="Mysite" />


Images & css not loaded - El Forum - 02-16-2009

[eluser]TheFuzzy0ne[/eluser]
What are the names of the directories where your CSS and images are stored? How are you including images and CSS into your views? Can you show an example?


Images & css not loaded - El Forum - 02-16-2009

[eluser]Exolead[/eluser]
Done & UP!!


Images & css not loaded - El Forum - 02-16-2009

[eluser]TheFuzzy0ne[/eluser]
Come again?


Images & css not loaded - El Forum - 02-16-2009

[eluser]Exolead[/eluser]
?? :roll:


Images & css not loaded - El Forum - 02-16-2009

[eluser]umefarooq[/eluser]
hi your base url is wrong

this is wrong
Code:
$config[‘base_url’]  = “http://localhost/mysite”;

this is right
Code:
$config[‘base_url’]  = “http://localhost/mysite/”;
put slash after mysite.

and for images use html helper function img() it will work fine. if you want to access images use

if you don't want to use html helper function than use like this.
Code:
<img src="&lt;?=base_url()?&gt;images/image.jpg" />

for css also

Code:
&lt;link type="text/css" rel="stylesheet" href="&lt;?=base_url()?&gt;css/css_file.css"&gt;
it will work fine.


Images & css not loaded - El Forum - 02-16-2009

[eluser]TheFuzzy0ne[/eluser]
Well spotted, umefarooq.


Images & css not loaded - El Forum - 02-16-2009

[eluser]Exolead[/eluser]
Thanks 10000 times, tnx tnx tnx, it works ^^.