Toby Chui 1 год назад
Родитель
Сommit
5458c0c64f
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      mod/dynamicproxy/redirection/handler.go

+ 7 - 2
mod/dynamicproxy/redirection/handler.go

@@ -30,8 +30,13 @@ func (t *RuleTable) HandleRedirect(w http.ResponseWriter, r *http.Request) int {
 		redirectTarget := rr.TargetURL
 		redirectTarget := rr.TargetURL
 
 
 		if rr.ForwardChildpath {
 		if rr.ForwardChildpath {
-			//Remove the first / in the path
-			redirectTarget += strings.TrimPrefix(r.URL.Path, "/")
+			//Remove the first / in the path if the redirect target already have tailing slash
+			if strings.HasSuffix(redirectTarget, "/") {
+				redirectTarget += strings.TrimPrefix(r.URL.Path, "/")
+			} else {
+				redirectTarget += r.URL.Path
+			}
+
 			if r.URL.RawQuery != "" {
 			if r.URL.RawQuery != "" {
 				redirectTarget += "?" + r.URL.RawQuery
 				redirectTarget += "?" + r.URL.RawQuery
 			}
 			}