Skip to main content

Where is Site content served from?

Definition: Document Root

Site content for a given domain or subdomain is served from its document root. A document root is the base folder from which all content is served. All accounts have a document root for the primary domain under /var/www/html. mainwebsite_html/ is a link to this location.

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

Whenever a domain is added through DNS > Addon Domains or subdomain created through Web > Subdomains, the directory specified will be the location from which content for that given domain or subdomain is served.

How it works

Consider example.com is an addon domain. The document root for this domain is /var/www/example.com. Accessing https://example.com/myfile.html would serve the file from /var/www/example.com/myfile.html. Accessing https://example.com/myimages/someimage.jpg would serve the file from /var/www/example.com/myimages/someimage.jpg and so on.

Be careful

As seen, whatever directory specified acts as location from which content is served. What if mydomain.com serves from /var/www/html and example.com serves from /var/www/html/example.com? It would be possible to reference content for example.com with a cleverly-crafted URL: https://mydomain.com/example.com/index.html points to the same file resource as https://example.com/index.html!

.htaccess rules for mydomain.com under /var/www/html would be applied to example.com. Any mod_rewrite, PHP, or general Apache directives will be applied to both mydomain.com and example.com. Unless sharing common directives among multiple sites is required, always place addon domains and subdomains under /var/www/.