Welcome Guest, Not a member yet? Register   Sign In
[Solved] CSS & Images (.htaccess problem)
#1

[eluser]kuysal[/eluser]
Hi,

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:

Code:
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?

Thanks...
#2

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

[eluser]kuysal[/eluser]
I've tried but this time I can't see both images and css on the whole site if I use leading slash.
#4

[eluser]kuysal[/eluser]
Actually, I've figured out that I have a problem at all of the controllers.

When I type

http://localhost/my-site/

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:

http://localhost/my-site/main/

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

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

???
#6

[eluser]kuysal[/eluser]
I've found where the problem is. I've used

../css/main.css

instead of

css/main.css

And everything got shiny Big Grin

Thanks for your help.




Theme © iAndrew 2016 - Forum software by © MyBB