[英]serve a single file irrespective of the location match in nginx
My current configuration is 我当前的配置是
server{
listen 80;
server_name some.com;
location /{
root /var/www;
index index.html;
}
}
This matches 这个匹配
/
-> /var/www/index.html
/
-> /var/www/index.html
/container
-> /var/www/container/index.html
/container
-> /var/www/container/index.html
I expect the location match not to be appended to the root. 我希望位置匹配项不会附加到根目录中。 So the matching will be
所以匹配将是
/
-> /var/www/index.html
/
-> /var/www/index.html
/container
-> /var/www/index.html
/container
-> /var/www/index.html
It will be same irrespective of the location, and I'll handle the render dynamically. 无论位置如何,它都是相同的,我将动态处理渲染。
The usual method is to use try_files
to provide a default URI: 通常的方法是使用
try_files
提供默认的URI:
server{
listen 80;
server_name some.com;
root /var/www;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
See this document for details. 有关详细信息,请参见此文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.