From dab6efb4241b29ca9ba5f9db30f065d33cb79956 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 2 Dec 2021 10:35:51 +0800 Subject: [PATCH] =?UTF-8?q?URL=E8=B7=B3=E8=BD=AC=E6=97=B6=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=89=8D=E5=90=8E=E8=B7=B3=E8=BD=AC=E7=9A=84URL?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E4=B8=80=E8=87=B4=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E6=97=A0=E9=99=90=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_host_redirect.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/nodes/http_request_host_redirect.go b/internal/nodes/http_request_host_redirect.go index 566c1b4..8672a44 100644 --- a/internal/nodes/http_request_host_redirect.go +++ b/internal/nodes/http_request_host_redirect.go @@ -27,6 +27,12 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { if u.KeepRequestURI { afterURL += this.RawReq.URL.RequestURI() } + + // 前后是否一致 + if fullURL == afterURL { + return false + } + if u.Status <= 0 { http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect) } else { @@ -60,6 +66,11 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { } } + // 前后是否一致 + if fullURL == afterURL { + return false + } + if u.Status <= 0 { http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect) } else { @@ -68,6 +79,11 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { return true } else { // 精准匹配 if fullURL == u.RealBeforeURL() { + // 前后是否一致 + if fullURL == u.AfterURL { + return false + } + if u.Status <= 0 { http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, http.StatusTemporaryRedirect) } else {