PHP

Kelly Landers
Kelly Landers
13,871 Points

404 Error- Localhost

I'm using Windows. I am trying to connect using localhost/test.php after I installed XAMMP. I keep getting a 404 error. I can't seem to figure it out.

13 Answers

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Cool! Let me know if you have any more trouble getting it to work. :~)

James White
James White
6,159 Points

Did you start the server? You have to launch the app then on the application you'll click a button to start servers.

Kelly Landers
Kelly Landers
13,871 Points

Yes I start running Apache. Correct ports and all. Could a Firewall have anything to do with it?

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Is the test.php file in the htdocs directory? How do you know its a 404 error and not a 500 error? What is the code in that test.php file?

Kelly Landers
Kelly Landers
13,871 Points

I have the test.php file in the htdocs folder. In that folder i have 3 other folders (forbidden, restricted & XAMMP) when i type in the site localhost/test.php it says the following...

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7

The code that is in the test.php file is this: <?php
"Hello World"; ?>

Kelly Landers
Kelly Landers
13,871 Points

It pulls up the orange XAMMP site from the video (looks like a homepage to me)

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Try adding an echo command to your test.php file:

<?php echo "Hello World"; ?>

(Without that echo statement, it won't display anything.) Any chance that fixes it?

Kelly Landers
Kelly Landers
13,871 Points

Not fixed. Same thing. I remember from your video that you did something with the firewall. Would that have anything to do with it? Im also running Vista.

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

If the ports or the firewall weren't set correctly, then I don't think you could see the localhost/xampp page.

What happens when you go just to [http://localhost/]?

Kelly Landers
Kelly Landers
13,871 Points

It won't let me. It defaults to the XAMMP page. localhost/xammp/

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

What folder is all this in? Is it [c:\xampp\htdocs]?

Kelly Landers
Kelly Landers
13,871 Points

Ahhh!!! There we go. The folder I had this on was a desktop shortcut. I wasn't using the above example and I remembered that part now. You are awesome thank you so much. Can't say enough good things about you guys!