---
title: "Where is site content served from?"
date: "2014-10-29"
category: "web-content"
slug: "where-is-site-content-served-from"
---

## Overview

Site content for a domain or subdomain is served from its **document root**: the base folder from which all web content is delivered. The primary domain's document root is `/var/www/html`. A convenience symlink `mainwebsite_html/` points to this location from your home directory.

### Home Directory Example

```
$ ls ~
drwx------ Aug 21 12:15 Mail
lrwxrwxrwx Aug 21 12:17 mainwebsite_html -> ../../var/www/html
```

When you add a domain via **DNS** > **Addon Domains** or create a subdomain via **Web** > **Subdomains**, the directory you specify becomes the document root for that hostname.

## How It Works

Consider `example.com` as an addon domain with its document root set to `/var/www/example.com`:

- `http://example.com/myfile.html` serves `/var/www/example.com/myfile.html`
- `http://example.com/myimages/someimage.jpg` serves `/var/www/example.com/myimages/someimage.jpg`

## Overlapping Document Roots

Be careful when nesting document roots. If `mydomain.com` serves from `/var/www/html` and `example.com` serves from `/var/www/html/example.com`, the content overlaps. A URL like `http://mydomain.com/example.com/index.html` would serve the same file as `http://example.com/index.html`.

Additionally, `.htaccess` rules for `mydomain.com` under `/var/www/html` would also apply to `example.com`. Any mod\_rewrite rules, [[changing-php-settings]], or other Apache directives would affect both domains.

**Best practice:** Unless you intentionally need to share directives across sites, always place addon domains and subdomains directly under `/var/www` rather than nesting them inside another domain's document root.
