I've recently installed MAMP, and localhost can't find the index file when I open the subdirectory even though it exists (HTTP ERROR 500).
My localhost is set to 90 in Apache. I've tried 80 and 8888, but none works. I am able to load localhost:90 correctly, but whenever I enter a subdirectory like http://localhost:90/01_FirstPage/, it can't find the index.php even though it exists.
This is the error in the log:
[04-Oct-2023 05:53:35 UTC] PHP Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0 [04-Oct-2023 05:53:35 UTC] PHP Fatal error: Failed opening required 'C:/Users/[user]/OneDrive/Documents/U/Web Programming 2/PHP course/CodeDynamicWebsites/CodeDynamicWebsites/01_FirstPage/index.php' (include_path='.;C:\php\pear') in Unknown on line 0
I also tried another browser. The code in the index file is:
<!DOCTYPE html>
<html>
<head>
<title>My First PHP Web Page</title>
</head>
<body>
<?php print('Hello World!'); ?>
</body>
</html>
How can I fix it?
I was following a tutorial on Udemy, so I changed the original directory when I first installed MAMP to a personal folder, and it wasn't working. After the comments mentioned
.htaccess, I looked up where to find this folder in MAMP. For Windows, it is saved inC:\MAMP\htdocs.I reset the directory and
localhostto its default in MAMP (C:\MAMP\htdocs., and apache:8888), and tried loadinglocalhost:8888again. It all loaded perfectly with theindex.phpfile insidehtdocs, so I replaced the content inside thehtdocsfolder with the files I needed and done!