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 Enhancing a Simple PHP Application Cleaning URLs with Subfolders Server Paths and Constants

Willie Allison
Willie Allison
2,035 Points

How do you use a root relative web address? I have tried the /contact and /contact.php.

How do you write a root-relative web address to come out of two folders? I have tried the http://localhost.contact which I knew wasn't the answer but the videos showed using "/" and I tried it and it didn't work either. I used the relative path in my code example which I knew wasn't right either. There just wasn't enough in the videos which I watched twice to get me through this code challenge.

about/leadership/index.php
<html>
<head>
     <title>Leadership | Shirts 4 Mike</title>
</head>
<body>

    <h1>Leadership</h1>
    <p><strong>Owner:</strong> ????</p>
    <p><a href= "/../../contact.php/">Contact</a></p>

</body>
</html>

Hey Willie! <p><a href= "/../../contact.php/">Contact</a></p> Let's say you own two folders. One inside of another. Your main folder is "images". And the sub-folder inside images is called "sportimg." Okay cool, let's now call the image named tennis.jpg using a relative path. We say it's Relative because it's inside of our project, it's not an external link. If we wanted to display this picture: <a href= "images/sportimg/tennis.jpg" alt= "Description"> I can see your using / to close the anchor statement. I would like to remind you Anchor statements are Self closing, so no need to use "/" after contact.php Hope this helped you. Feel free to message me if you need any other help.

Willie Allison
Willie Allison
2,035 Points

Mat I rewatched the video and you were right about the end not needing the "/" but I still haven't gotten past this part of the code challenge. Thank you for your help.

Willie Allison Be sure not to start with / aswell. And make sure to type everything very carefully as it is self-sensitive. Remember we use ".." to go up one level.

1 Answer

Change: /../../contact.php

to

../../contact.php

I think you just have a typo. The "../" will always pull you exactly one level closer to the root each time its repeated.

Willie Allison
Willie Allison
2,035 Points

Sava that is a cool name my friend. sadly what you suggested didn't work. I rewatched the video on root relative web addresses and it only shows starting your url with the "/" and then the file name you are looking for but yet it didn't work in the code challenge. I tried your way as well and it didn't work either. Thank you for your help.