我正在尝试在 apache 2.4 中实现维护页面而无需重新启动和特定的 503 错误代码。我正在关注这个网站https://www.shellhacks.com/redirect-site-maintenance-page-apache-htaccess/
下面是我的 html 文件,图像文件maintenance.svg也在同一个根 htdocs 文件夹中:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body, html {
height: 100%;
margin: 0;
/* The image used */
background-image: url("maintenance.svg");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
</style>
</head>
<body>
</body>
</html>
重写规则如下:
DocumentRoot "${SRVROOT}/htdocs"
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [L]
ErrorDocument 503 /maintenance.html
我不是 Apache 专家,需要您的帮助才能使用重写规则加载图像。