diff --git a/internal/nodes/http_request_host_redirect.go b/internal/nodes/http_request_host_redirect.go index 39e9d7a..8cec3e9 100644 --- a/internal/nodes/http_request_host_redirect.go +++ b/internal/nodes/http_request_host_redirect.go @@ -73,6 +73,13 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { return false } + if u.KeepArgs { + var qIndex = strings.Index(this.uri, "?") + if qIndex >= 0 { + afterURL += this.uri[qIndex:] + } + } + if u.Status <= 0 { this.processResponseHeaders(http.StatusTemporaryRedirect) http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect) @@ -88,12 +95,20 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) { return false } + var afterURL = u.AfterURL + if u.KeepArgs { + var qIndex = strings.Index(this.uri, "?") + if qIndex >= 0 { + afterURL += this.uri[qIndex:] + } + } + if u.Status <= 0 { this.processResponseHeaders(http.StatusTemporaryRedirect) - http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, http.StatusTemporaryRedirect) + http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect) } else { this.processResponseHeaders(u.Status) - http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, u.Status) + http.Redirect(this.RawWriter, this.RawReq, afterURL, u.Status) } return true }