Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Slim Basics & Twig Templates Including & Rendering

Solved: CSS not loading

I've got slim routing to the files in my templates folder just fine, but for some reason, the CSS, JavaScript, and image files are not loading. Both Chrome and Safari get a 404 error when trying to retrieve them. It looks like they're trying to get the files from the right places - <workspaceURL>/css, etc.

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Ralph Waldo Emerson</title>
  <meta name="description" content="Ralph Waldo Emerson">
  <meta name="author" content="Treehouse">
  <link href='http://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="css/master.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script src="js/global.js"></script>
</head>

<!--- Other stuff here --->

</html>

Anyone have an idea as to what could be the problem?

2 Answers

James MacDonald
PLUS
James MacDonald
Courses Plus Student 6,268 Points

Hi Greg,

Not sure where your files are located, but you may want to point to /css rather than css.

/css refers to your root directory, then the css directory, whereas css refers to the css directory relative to the document's location

Hope that helps,

-Jamie

That's what I thought as well, but changing the file path doesn't fix it. The browsers seem to be looking in the right spot regardless. For instance, this is the path Chrome spits out in the console error: http://port-80-zenoxj7e7r.treehouse-app.com/css/master.css

That is exactly how I fixed mine as well.

I fixed it. Something was wrong with my .htaccess file. Not sure what, but I had tried typing it out instead of copying and pasting it like a reasonable adult.