|
@@ -30,8 +30,13 @@ func (t *RuleTable) HandleRedirect(w http.ResponseWriter, r *http.Request) int {
|
|
|
redirectTarget := rr.TargetURL
|
|
|
|
|
|
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 != "" {
|
|
|
redirectTarget += "?" + r.URL.RawQuery
|
|
|
}
|