I have a simple default website configuration located in my "sites-available" folder in nginx that looks like the one below.
When I try browse to /hello I'd expect it to serve the index.html file located in the root folder I specified. Instead, it is trying to get /hello/index.html within the root location I specified.
Is there a way to tell nginx to serve the files without prefixing the context path?
root /var/...;
location / {
...
}
location /hello/ {
root /home/vagrant/public_html/project/dist;
}
Best Answer
Use
alias
instead ofroot
; quoting http://nginx.org/en/docs/http/ngx_http_core_module.html#alias