Welcome Guest, Not a member yet? Register   Sign In
targeting images and css
#1

[eluser]jvittetoe[/eluser]
whenever i try to view the images in my images directory, i get a 404. what am i doing wrong here? i have my structure as is...and from my css files, any background images im targeting are not showing.
#2

[eluser]jvittetoe[/eluser]
from my main layout file

Code:
<link rel="stylesheet" href="<?=base_url();?>static/css/master.css" type="text/css" media="screen"/>

when viewing source,
Code:
http://localhost/pr0jects/myFinance/static/css/master.css

my directory structure, I have attempted moving the static folder inside of application, but to no avail.
/myFinance
-/application
-/system
-/static
--/css

my baseURL as defined in config,
Code:
http://localhost/pr0jects/myFinance/
#3

[eluser]John_Betong[/eluser]
 
Hi jvittetoe,

Immediately before your link statement try this:

Code:
<?php
    echo '<br />site_url() --&gt; ' .site_url();
    echo '<br />base_url() --&gt; ' .base_url();
    echo '<br />getcwd() ----&gt; ' .getcwd();
    echo '<br />link path ---&gt;'  .base_url() .'static/css/master.css';
    die;
  ?&gt;

Cheers,

John_Betong
&nbsp;
#4

[eluser]Michael Wales[/eluser]
is your application within the root directory on the server (htdocs, webroot, etc)? If so, you are referencing a directory name pr0jects that doesn't exist.

If not, possibly try altering your file structure and placing the CSS and images in within an assets folder that you can reference from root. It makes your relative URLs much simpler:

Code:
&lt;link rel="stylesheet" type="text/css" href="/assets/css/style.css" media="all" /&gt;
<img src="/assets/img/thumb.jpg" />
#5

[eluser]jvittetoe[/eluser]
site_url() --&gt; http://localhost/pr0jects/myFinance/
base_url() --&gt; http://localhost/pr0jects/myFinance/
getcwd() ----&gt; /Users/joshvittetoe/_wwwroot/pr0jects/myFinance
link path ---&gt;http://localhost/pr0jects/myFinance/static/css/master.css

that is what i get...

my localhost root directory is /_wwwroot/

inside there i have numerous folders including a projects directory which is my repository for any applications or tests that i conduct which are given their own folders inside their, like /myFinance/

it should be to where i can have an individual css directory for an app and shouldn't need to reside one level up, in my root.

when i do navigate to the /pr0jects/myFi.../static/ directory, im given a 404, it seems my app is thinking im trying to call a controller, i cant even navigate to the actual css file without showing a 404.
#6

[eluser]Michael Wales[/eluser]
Sounds like you jacked up your .htaccess file. You should have a rewrite exception in there to keep requests for your static subdirectory from going to index.php.

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

[eluser]John_Betong[/eluser]
[quote author="jvittetoe" date="1195645727"]site_url() --&gt; http://localhost/pr0jects/myFinance/
base_url() --&gt; http://localhost/pr0jects/myFinance/
getcwd() ----&gt; /Users/joshvittetoe/_wwwroot/pr0jects/myFinance
link path ---&gt;http://localhost/pr0jects/myFinance/static/css/master.css

that is what i get...

my localhost root directory is /_wwwroot/

inside there i have numerous folders including a projects directory which is my repository for any applications or tests that i conduct which are given their own folders inside their, like /myFinance/

it should be to where i can have an individual css directory for an app and shouldn't need to reside one level up, in my root.

when i do navigate to the /pr0jects/myFi.../static/ directory, im given a 404, it seems my app is thinking im trying to call a controller, i cant even navigate to the actual css file without showing a 404.[/quote]

Hi jvittetoe,

What happens when you type this into your browser?
Quote:http://localhost/pr0jects/myFinance/stat...master.css
&nbsp;
If that displays your CSS file Ok then this is the magic line that I use to call a background image which resides in the same directory.
Quote:body {background:#ffffff url(grad_green.jpg) 0 0 repeat-x; color:#000}
&nbsp;
I try to work from simple code/image paths that work then try other more complicated paths.

Cheers,

John_Betong
&nbsp;
#8

[eluser]frankthetank[/eluser]
Thanks! Helped me as well.
#9

[eluser]jvittetoe[/eluser]
[quote author="jvittetoe" date="1195645727"]
Hi jvittetoe,

What happens when you type this into your browser?
Quote:http://localhost/pr0jects/myFinance/stat...master.css
[/quote]
i get a CI 404 error, here is what my htaccess file reads, it is located in my, localhost/projects/myFinance/ directory, along side my application, system and static folders
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|js|images|system\/plugins|robots\.txt|css\/)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
#10

[eluser]Michael Wales[/eluser]
Like I said, you are not making an exception for your static directory - therefore, CI is trying to find a controller named static, a method named css, and passing a paramter of master.css

Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|js|images|systems\/plugins|static|robots\.txt|css\/)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>




Theme © iAndrew 2016 - Forum software by © MyBB