From 0d04c872aa48217f1eb1411e01133980750f862b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sat, 17 Jan 2026 00:59:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E7=BD=91=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/webserver/apache/vhost.go | 5 ++--- pkg/webserver/nginx/vhost.go | 12 +++++------- 2 files changed, 7 insertions(+), 10 deletions(-) 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) }