Skip to content
MAMP Documentation

The document root

The document root is the folder on your Mac that the web server treats as the starting point for all web requests. It maps a URL to a file on disk.

When your browser requests http://localhost:8888/hello.html, Apache does not search your entire Mac for a file named hello.html. It looks only inside the document root folder. The URL path after the port number maps directly to the file system path inside that folder:

URLFile on disk
http://localhost:8888/hello.html/Applications/MAMP/htdocs/hello.html
http://localhost:8888/projects/site/index.php/Applications/MAMP/htdocs/projects/site/index.php

MAMP’s default document root is /Applications/MAMP/htdocs/. The recommended setup is one project per document root:

  • DirectoryApplications/
    • DirectoryMAMP/
      • Directoryhtdocs/
        • index.php
        • style.css
        • Directoryimages/
          • logo.png

Files inside the document root are accessible through the browser. Files outside it are not. This boundary is not a limitation — it is an intentional security feature. A visitor to your local server cannot request files from arbitrary locations on your filesystem.

This has a practical implication: sensitive files such as configuration files with database passwords should always be stored outside the document root, where they cannot be served by accident.

You can change the document root at any time in Settings › Server. A common reason to do this is to point MAMP directly at a project folder, so that http://localhost:8888/ opens that project rather than the default htdocs folder.

For example, if you are working on a project at ~/Sites/my-project/, you can set that as the document root and access it at http://localhost:8888/ without putting it inside the MAMP folder at all.

Changing the document root does not move or delete any files. It only changes which folder the web server looks in when handling requests. The previous folder and its contents remain untouched.

The document root and index.php / index.html

Section titled “The document root and index.php / index.html”

When a URL ends with a folder path rather than a specific filename – for example http://localhost:8888/ – Apache looks for a default file inside that folder. By convention, this is index.php or index.html. If neither exists, Apache displays a directory listing – a plain list of files and folders in that directory. This is the default behavior in MAMP’s standard configuration.

This is why placing an index.php or index.html in your document root is enough to make it load automatically when you open http://localhost:8888/ in a browser.