localhost can't find file even though it exists (HTTP ERROR 500), MAMP server

111 Views Asked by At

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?

1

There are 1 best solutions below

0
starfish On

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 in C:\MAMP\htdocs.

I reset the directory and localhost to its default in MAMP (C:\MAMP\htdocs., and apache: 8888), and tried loading localhost:8888 again. It all loaded perfectly with the index.php file inside htdocs, so I replaced the content inside the htdocs folder with the files I needed and done!