重定向 nginx / 在 / v2 /

我有一个位置 nginx, 如下:

location / {
alias /usr/share/nginx/myapp/dist/;
gzip_static on;

# Media: images, icons and fonts
location ~* \.(?:jpg|jpeg|png|ico|otf)$ {
expires 2M;
access_log off;
add_header Cache-Control "public";
}

# CSS, HTML and Javascript
location ~* \.(?:css|js|html)$ {
expires 4h;
access_log off;
add_header Cache-Control "public";
}
}

但由于某种原因,许多用户没有得到我最新的更新 index.html. 由于它非常重要,并且许多用户抱怨,我想重定向每个请求 / (/index.html, / # / myTeam) 在 / v2 / (/v2/index.html, / v2 / # / myTeam). 所以我知道用户的缓存不是问题。

Iv'e 创造了一个名为的新地方 / v2 / 并在那里移动一切,然后改变了 / 在:

 # Serve locations
location / {
return 301 /v2/;
}

但它没有工作。 还试图重写稍微重写。 我可以重定向 /?
已邀请:

莫问

赞同来自:

您重定向每个请求

/blah/blah/whatever

, 简单

/v2/

什么不是你想要的。

location / {
return 301 /v2$request_uri;
}

保存原稿要求 URI, 添加到它

/v2/

.

要回复问题请先登录注册