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

#1
[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" />

#2
[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?

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

#4
[eluser]TheFuzzy0ne[/eluser]
Come again?

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

#6
[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.

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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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