How can I map a URI of the form staging.example.com/siteA
to a virtual server located at /var/www/siteA
?
The main restriction is that I do not want to create a subdomain for siteA. All examples of nginx.conf I've seen so far rely on having a subdomain to do the mapping.
Thanks
You may use the root directive within a
location
block, like this:Then
http://staging.example.com/foo.txt
points to/some/other/location/foo.txt
, whilehttp://staging.example.com/siteA/foo.txt
points to/var/www/siteA/foo.txt
.Note that the
siteA
directory is still expected to exist on the filesystem. If you wanthttp://staging.example.com/siteA/foo.txt
to point to/var/www/foo.txt
, you must use thealias
directive: