[英]NGINX, How to use same location path for different target folder?
我正在尝试在 nginx 中使用相同的位置路径。
location = / {
root /usr/share/nginx/html/main;
try_files $uri /index.html;
}
location / {
root /usr/share/nginx/html/app;
try_files $uri /index.html;
}
但它正在渲染应用程序文件夹。
我正在尝试在“/”路径的情况下呈现“主”文件夹 html 文件,在任何其他路径的情况下呈现“app”文件夹 html 文件。
您不能使用相同的位置,您需要为不同的文件夹使用不同的位置。 即使您看到使用多个点的“try_files”,“位置”也是不同的。
但是,您可以使用多个位置,例如“/media”中的媒体和“/”中的 html 内容或其他内容。
例子
location /media {
root /usr/share/nginx/html/app;
try_files $uri /index.html;
}
location / {
root /usr/share/nginx/html/main;
try_files $uri /index.html;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.