1

Hey everyone, I'm new to PHP and I'm trying to setup a project locally with Netbeans on mac. I have used MAMP to setup my apache server and I test it and the server is running. However when trying to run my simple hello world PHP project I get a 404 not found:

Current URL used for project: http:/localhost/PhpProject1/index.php

Error: The requested URL /PhpProject1/index.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

My project is found under: /Applications/MAMP/dtdocs/PhpProject1/

Dir Tree for www: MAMP>htdocs>PhpProject1>index.php

Community
  • 1
  • 1
Staleyr
  • 643
  • 4
  • 8
  • 12
  • 2
    Show your dir structure to the www folder. – Hackerman Feb 21 '13 at 19:32
  • Try `http://localhost/htdocs/PhpProject1/index.php` – HamZa Feb 21 '13 at 19:48
  • Thanks, i just tried this ^^ and still gives the 404. I dont understand because i can see the file is there, and i have also set RW permissions to the entire folder to be sure. – Staleyr Feb 21 '13 at 19:51
  • @user1515668 are you sure that you have started Apache ? Otherwise try `127.0.0.1` instead of `localhost`. – HamZa Feb 21 '13 at 19:55
  • I owe you a beer my friend, by switching localhost with 127.0.0.1 it works. Why is this? MAMP specifies that you should use localhost when referring to the dtdocs folder? – Staleyr Feb 21 '13 at 20:03
  • @Staleyr i have no idea, you may take a look [here](http://serverfault.com/a/76212) – HamZa Feb 21 '13 at 20:10
  • Maybe MAC treats "localhost" differently to Windows and Linux? – EM-Creations Feb 22 '13 at 13:28
  • `localhost` might resolve to your local IPv6 address (I'm not a Mac user but perhaps the `ping localhost` command can clarify that). If Apache is listening to IPv4 address then you'll get no matches. I can't see though what your IDE has to do with the question. – Álvaro González Feb 14 '21 at 19:08

1 Answers1

-1

I also had this issue, here is how I solved it in Xampp:

Create your folder in htdoc

C:\xampp\htdocs\FolderName\phpfile.php

To run this file the URL will be set as:

http://localhost/FolderName/phpfile.php

That's it.. Enjoy :)

Dayo Jaiye
  • 948
  • 1
  • 10
  • 17