diff --git a/pkg/webserver/apache/vhost.go b/pkg/webserver/apache/vhost.go index 1a22bf77..8caec770 100644 --- a/pkg/webserver/apache/vhost.go +++ b/pkg/webserver/apache/vhost.go @@ -121,11 +121,10 @@ func (v *baseVhost) SetEnable(enable bool) error { return fmt.Errorf("failed to remove disable config: %w", err) } } else { - // 禁用:写入重定向规则,所有请求返回禁用页面 + // 禁用:所有请求重写到禁用页面 content := fmt.Sprintf(`# Auto-generated by AcePanel. DO NOT EDIT MANUALLY! RewriteEngine On -RewriteRule ^ - [R=503,L] -ErrorDocument 503 %s +RewriteRule ^ %s [L] `, DisablePage) if err := os.WriteFile(disableConf, []byte(content), 0600); err != nil { return fmt.Errorf("failed to write disable config: %w", err) diff --git a/pkg/webserver/nginx/vhost.go b/pkg/webserver/nginx/vhost.go index 7a8cac2d..0fe9306c 100644 --- a/pkg/webserver/nginx/vhost.go +++ b/pkg/webserver/nginx/vhost.go @@ -117,15 +117,13 @@ func (v *baseVhost) SetEnable(enable bool) error { return fmt.Errorf("failed to remove disable config: %w", err) } } else { - // 禁用:写入 return 规则,所有请求返回禁用页面 + // 禁用:所有请求重写到禁用页面 content := fmt.Sprintf(`# Auto-generated by AcePanel. DO NOT EDIT MANUALLY! -error_page 503 @stop; -return 503; -location @stop { - default_type text/html; - alias %s; +rewrite ^ /stop.html last; +location = /stop.html { + root %s; } -`, DisablePage) +`, filepath.Dir(DisablePage)) if err := os.WriteFile(disableConf, []byte(content), 0600); err != nil { return fmt.Errorf("failed to write disable config: %w", err) }