diff --git a/server/upstream/redirects.go b/server/upstream/redirects.go index 3ed5010..b0762d5 100644 --- a/server/upstream/redirects.go +++ b/server/upstream/redirects.go @@ -92,8 +92,9 @@ func (o *Options) matchRedirects(ctx *context.Context, giteaClient *gitea.Client for _, redirect := range redirects { if dstURL, ok := redirect.rewriteURL(reqURL); ok { - // do rewrite if status code is 200 - if redirect.StatusCode == 200 { + if o.TargetPath == dstURL { // recursion base case, rewrite directly when paths are the same + return true + } else if redirect.StatusCode == 200 { // do rewrite if status code is 200 o.TargetPath = dstURL o.Upstream(ctx, giteaClient, redirectsCache) } else {