Nginx configuration for multiple static sites on same server instance
The pathname of the requested file is constructed by concatenating the value of root
directive with the URI. So you can only use root
with subfolders if (for example) second_path
and second_folder
is actually the same name. See this document for details.
For example:
location /foo { root /path/to/root;}
The URI /foo/index.html
is located at /path/to/root/foo/index.html
Where second_path
and second_folder
are different names, you will need to use the alias
directive. See this document for details.
For example:
location /foo { alias /path/to/root/bar;}
The URI /foo/index.html
is located at /path/to/root/bar/index.html