• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems With CSS and Images

#1
[eluser]Dazeone[/eluser]
Hello everyone,

I'm hoping someone can see where I'm going wrong here. I'm using the following code in my .htaccess file (I have tried as many versions as I can find). I have cleared index.php out of the config file and set the uri_protocol to AUTO.

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

My homepage loads up properly. However when I access other controllers (ex. "domain.com/members/login") it acts as if it is actually in a "/members/login" directory and therefor cannot find my css and image files which are located at domain.com/css and domain.com/images. I can access those files directly so I don't think it's a permission issue. I am using shared hosting with network solutions.

Please help!?!

#2
[eluser]appleboy[/eluser]
Please show your views code, and explain where css and image path you placed.

Check CSS or image url directly.

ex:
Code:
# check file exist
xxx.xxx/images/a.png

#3
[eluser]Dazeone[/eluser]
Here is the CSS link in the "header_view.php" file (stored in application/views)

Code:
<link rel="stylesheet" href="css/style.css" />

Here is an example of an image

Code:
<img src="images/logo.png" alt="{page_title}" />

they are located at domain.com/css/style.css and domain.com/images/logo.png. Both work on the main view but not through other controllers. Is this an html problem?

#4
[eluser]appleboy[/eluser]
please modified your .htaccess as follows

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

please show the config value (stored in application/config/)

Code:
$config['base_url']

try the following code:
Code:
&lt;link rel="stylesheet" href="/css/style.css" /&gt;
<img src="/images/logo.png" alt="{page_title}" />

#5
[eluser]Dazeone[/eluser]
omg...

It works...

I just wanna cry...

Thanks for your help!

#6
[eluser]jblack199[/eluser]
what i did was put my css, images and js in an inc folder in the root and use .htaccess similar to what appleboy posted above, except i changed this line:

RewriteCond $1 !^(index\.php|css|images|robots\.txt)

to

RewriteCond $1 !^(index\.php|inc|robots\.txt)


makes for cleaner file structure imo.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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