[英]Nginx configuration to serve any url as root url
I am running a simple static website under nginx with the following configuration我在nginx下运行一个简单的静态网站,配置如下
server {
listen 80;
listen [::]:80;
location /mycalendar {
root /usr/share/nginx/html;
index index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
The catch:捕获:
URLs are coming in to this service as /mycalendar. URL 以 /mycalendar 的形式进入此服务。 However nginx still expects to find files in a "mycalendar" subdir of /usr/share/nginx/html but I would like to server them from the "root".
然而,nginx 仍然希望在 /usr/share/nginx/html 的“mycalendar”子目录中找到文件,但我想从“root”中为它们提供服务。
Is there a way to serve a /mycalendar subpath but tell nginx to take files from root instead of a subdirectory named after the subpath?有没有办法为 /mycalendar 子路径提供服务,但告诉 nginx 从根目录而不是以子路径命名的子目录中获取文件?
Thanks!谢谢!
在这种情况下有帮助的是在“location ~ /mycalendar”块中使用“alias”而不是“root”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.