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 trialTunde Adegoroye
20,597 PointsRoot relative path not working
I have followed the video where you use the / to direct right back to the root of the server but it doesn't seem to work at all i am currently running MAMP and have followed everything. Everything in the include files such as links and css are just not working at all
header include file
<html>
<head>
<!-- Gets the value of the variable pageTitle from page its inserted into
places it as the title of the page -->
<title><?php echo $pageTitle; ?></title>
<link rel="stylesheet" href="/css/style.css" type="text/css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css">
<link rel="shortcut icon" href="/favicon.ico">
</head>
<body>
<div class="header">
<div class="wrapper">
<h1 class="branding-title"><a href="/index.php">Shirts 4 Mike</a></h1>
<ul class="nav">
<!-- The if statement checks the value of the variable section on the page that it has been inserted
onto depending on the variable it will add the class to the list item-->
<li class="shirts <?php if ($section == "shirts"){ echo "on";} ?>"><a href="/shirts.php">Shirts</a></li>
<li class="contact <?php if ($section == "contact"){ echo "on"; }?> "><a href="/contact.php">Contact</a></li>
<li class="cart"><a target="paypal" href="https://www.paypal.com/cgi-bin/webscr?cmd=_cart&business=QKGCFGLK289HC&display=1">Shopping Cart</a></li>
<li class="about <?php if ($section == "about"){ echo "on"; }?> "><a href="/about.php">About</a></li>
</ul>
</div>
</div>
5 Answers
Tunde Adegoroye
20,597 PointsJust read another issue like mine to fix this if you have more than one project folder in your htcdocs you have to specify the project name after the slash and then the file i.e.
/shirts4mike/css/styles.css
or for a single file outside of a folder
/shirts4mike/shirts.php
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Tunde
your code looks fine to me. have you got all your files in a subfolder in your htdocs folder?? ie when you access your index page do you type in just localhost or localhost/'foldername'?? if you have got your files in a subfolder than the path would be /yourfoldername/css/style.css
Tunde Adegoroye
20,597 PointsI just answered my own question but thanks for the reply though :)
Muhammad Babar
1,048 Pointshello Andreas cormack,
i have a question that when we'll type our sub folder name in the link and when we'll upload the full web on the server than we'll upload the files instead of the folder and in this case the links will be broken. So please tell me the solution for this....
visa atchabad
Courses Plus Student 1,098 PointsSAVED me hours thanks
visa atchabad
Courses Plus Student 1,098 PointsSAVED me hours thanks
Jerôme Naglé
14,189 PointsJerôme Naglé
14,189 Points(Y)!!!
Bob Sutherton
20,160 PointsBob Sutherton
20,160 PointsSaved me a headache. Thanks!
Kevin Boller
13,768 PointsKevin Boller
13,768 PointsCool -- had the same issue. Thanks for posting.
Aaron Munoz
11,177 PointsAaron Munoz
11,177 PointsThanks for taking initiative!
Paul Yorde
10,497 PointsPaul Yorde
10,497 PointsYup, thanks!