Link href not finding stylesheet

Hey all,

I have a simple link tag in head tag:


<link rel="stylesheet" type="text/css" href="../public/stylesheets/application.css" />

The file is located in template.php. The directory it’s in is called views and a directory called public is at the same level as views. So I go one directory up to get to public and then there’s a directory called stylesheets in public and a file called application.css within that. So I am not sure why the browser can’t find the stylesheet.

Thanks for response.

Is template.php the file requested by the browser? The stylesheet has to be defined relative to the file that is requested by the browser, so if you were to have an index.php in another directory and that index.php includes your template.php you need to specify the CSS relative to index.php, not to template.php

Thanks for the response. When the user goes to the home page, for example, it triggers the show method of the categories class (which is itself a ‘controller’ in mvc). That show method populates show.php in categories directroy with data depending on what posts have been associated with the category ‘home’. Then that show.php results gets put into template.php, which contains the header info and this gets called:


return $this->CI->load->view($template, $this->template_data, $return);

$template refers to template.php and template data is the data from show.php. This load->view is called within a library called Template.php

So I am not even clear myself what actual file the server is requesting since a lot of files are being requested.

Ah you’re using CodeIgniter? In that case you most likely have an index.php in de document root that all requests are routed through (using a .htaccess file). The ‘public’ directory is your document root I assume?

If so, try /stylesheets/application.css instead of …/public/stylesheets/application.css

thanks for response, I ended up using site_url() function and then the destination to the public folder from there.