【发布时间】:2020-01-10 00:02:14
【问题描述】:
我在 NGINX 中添加了带有重写指令的斜杠。目前我正在这样做:
# 301 Redirect for trailing slash
location ~ ^([^.]*[^/])$ {
try_files $request_uri @addslash;
}
# 301 Redirect for trailing slash
location @addslash {
return 301 $uri/$is_args$args;
}
它可以工作,但仅在端口 80 上。现在我正在寻找一种方法来重写此构造的第二部分以转发到正确的端口。
我找到了this discussion that explains how to forward to the correct port。但它不会按原样转发 uri 的其余部分。不考虑端口之后的部分。对于我的构造,那将是 the "path" portion of the uri。
哪个 nginx 变量只包含路径部分?或者 uri 中端口之后的所有内容?
还有:有人知道带有示例的 nginx 变量列表吗? The one from the documentation 在这种情况下并没有真正的帮助:-P
【问题讨论】: