• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Images & css not loaded

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;

$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

These are my directories:

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" />

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?

Done & UP!!

Come again?

?? :roll:

hi your base url is wrong

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

this is right
$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.
<img src="&lt;?=base_url()?&gt;images/image.jpg" />

for css also

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

Well spotted, umefarooq.

Thanks 10000 times, tnx tnx tnx, it works ^^.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.