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

"localhost" url doesn't bring me to htdocs folder

While a couple minutes ago I was happily programming in php, all of a sudden when I pressed the refresh button I got an error : Not Found The requested URL /MAMP/contact.php was not found on this server. This was in place of contact.php. When I redirected the browser to localhost, the page said: Index of/ ... and then a list of files. I realized these files are the files located in my WebServer/Documents folder. This would mean localhost looks for files in this Documents folder instead of it the htdocs folder. It was working fine a short while ago.... Any help is appreciated. Thanks!

  • John

5 Answers

Dan Ridley
PLUS
Dan Ridley
Courses Plus Student 14,839 Points

Hey John Sanchez ,

I am sorry you are having a problem.

Let me tag Randy Hoyt for us to try and help us solve this problem for you.

John Locke
John Locke
15,479 Points

You might have to listen on a different port, sometimes applications such as Skype take up the default Port 80.

When I go to [http://localhost/MAMP/], I get the same error.

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

It sounds like http://localhost/MAMP/ is pointing at your htdocs directory. It also sounds like you have an error in your PHP file. If there's an error and nothing output gets sent to the browser, then the browser will respond with that error. In your contact.php file, type something like "Hello?" at the very top (before the first opening PHP tag) and then visit [http://localhost/MAMP/contact.php]. Does the browser display the message?

Nothing happens...I get the error: Not Found The requested URL /contact.php was not found on this server.

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

Which address are you looking at?

Can you try both of them (with that "Hello" message in it)? I can't quite tell what's going on, but I think the first one will work.

If neither of them work, can you create a new file in your htdocs directory named [test.html], put text like "Hello?" in it, and then try each of these?

I'm having the same problem. Only the http://localhost/contact.php address seems to be working.

Type in http://localhost:8888 instead.