• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] CSS & Images (.htaccess problem)


I've been developing a site I use .htaccess to route requests. But I can only see the css file and the images are applied on the main controller (my default controller). When I use another controller I see css and images are nor loaded. Here is the .htaccess file I use:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

I don't know the details of the .htaccess code lines and what they are exactly doing. The css files and located under the root folder ({root}/css) and so the images {root/images}.

Any help?


[eluser]Glen Swinfield[/eluser]
You are most likely using relative paths to call your images and CSS e.g

<link rel="stylesheet" scr="css/sheet.css" .... />

You need to use

<link rel="stylesheet" scr="/css/sheet.css" .... /> (note the leading slash)

.htaccess is fine - REQUEST_FILENAME means if file/directory (-f, -d) exists do not redirect/rewrite.

I've tried but this time I can't see both images and css on the whole site if I use leading slash.

Actually, I've figured out that I have a problem at all of the controllers.

When I type


The controller named 'main' loads by default as I've configured and everything is OK. But when I try to reach the main controller manually by typing:


Images and css are not loaded. I've tried moving the folders under /system folder but nothing changed.

[eluser]Glen Swinfield[/eluser]
Sorry, I assumed you would be using a virtual host (www.mydevsite.com.dev) or something, looks like you need to use these paths:

<link rel="stylesheet" scr="/my-site/css/sheet.css" .... /> wher 'my-site' is the name of the root-folder your site is in.


I've found where the problem is. I've used


instead of


And everything got shiny Big Grin

Thanks for your help.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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