部署前端应用到路径的nginx配置问题?

项目部署到/app路径上,以下有两种nginx配置。
可以正确访问到应用,但会从 /app 301 到 /app/,目前不希望出现跳转。
server {  listen 80;
  server_name ng.ct.com;
  expires 7d;
  location /app {
    root D:/code;
    index  index.html;
    try_files $uri $uri/ /app/index.html;
  }
}
不可以正确访问到应用,为什么???
如果要在这种配置下正确访问,应该还需要做什么?
server {  listen 80;
  server_name ng.ct.com;
  expires 7d;
  location /app {
    root D:/code/app;
    index  index.html;
    try_files $uri $uri/ /index.html;
  }
}
最终目的是,可以通过 /app 访问应用,而不出现301跳转。
回答:
可以尝试使用端口绑定到app目录,然后用反向代理访问
回答:
try_files $uri $uri/ /app/index.html;
标红的设置去掉. 你自己都配置是先访问文件夹了.
以上是 部署前端应用到路径的nginx配置问题? 的全部内容, 来源链接: utcz.com/p/935650.html






