HTTP directives

root directive (HTTP)

Sets the filesystem base used to map a request URI to a path. Context: http, server, location, or if in location. Default: html. The request URI path is appended to the root; the alias directive has different mapping rules. Example is a partial configuration for the supplied isolated lab; do not paste it into a running host configuration.

Formal Syntax & Structure

nginx syntaxnginx
root path;

Parameters & Attributes

NameTypeDescription
pathstringDirectory path; relative paths are resolved against the Nginx prefix.

Working Example

Example Snippetnginx
location /docs/ {    root html;}# /docs/help.html maps to html/docs/help.html
Nginx Reference