diff --git a/pkg/serverconfigs/http_host_redirect_config.go b/pkg/serverconfigs/http_host_redirect_config.go index 379ff17..a1f2e73 100644 --- a/pkg/serverconfigs/http_host_redirect_config.go +++ b/pkg/serverconfigs/http_host_redirect_config.go @@ -65,7 +65,7 @@ func (this *HTTPHostRedirectConfig) BeforeURLRegexp() *regexp.Regexp { // MatchRequest 判断请求是否符合条件 func (this *HTTPHostRedirectConfig) MatchRequest(formatter func(source string) string) bool { - if this.Conds == nil { + if this.Conds == nil || !this.Conds.HasRequestConds() { return true } return this.Conds.MatchRequest(formatter) diff --git a/pkg/serverconfigs/http_location_config.go b/pkg/serverconfigs/http_location_config.go index 46985ec..487b1b5 100644 --- a/pkg/serverconfigs/http_location_config.go +++ b/pkg/serverconfigs/http_location_config.go @@ -260,7 +260,7 @@ func (this *HTTPLocationConfig) ExtractPattern() error { // TODO 支持子Location func (this *HTTPLocationConfig) Match(path string, formatter func(source string) string) (vars map[string]string, isMatched bool) { // 判断条件 - if this.Conds != nil && !this.Conds.MatchRequest(formatter) { + if this.Conds != nil && this.Conds.HasRequestConds() && !this.Conds.MatchRequest(formatter) { return } diff --git a/pkg/serverconfigs/http_rewrite_rule.go b/pkg/serverconfigs/http_rewrite_rule.go index fe4910f..90f0788 100644 --- a/pkg/serverconfigs/http_rewrite_rule.go +++ b/pkg/serverconfigs/http_rewrite_rule.go @@ -90,7 +90,7 @@ func (this *HTTPRewriteRule) MatchRequest(requestPath string, formatter func(sou } // 判断条件 - if this.Conds != nil && !this.Conds.MatchRequest(formatter) { + if this.Conds != nil && this.Conds.HasRequestConds() && !this.Conds.MatchRequest(formatter) { return "", nil, false }