mod-rewrite - Apache 2.4 维护 html 页面图像未加载
问题描述
我正在尝试在 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 专家,需要您的帮助才能使用重写规则加载图像。
解决方案
最后的 RewriteCond 是重写的异常。您可以添加另一个,它与以前的隐式与:
RewriteCond %{REQUEST_URI} !maintenance.svg
推荐阅读
- postgresql - 是否可以使用 pg-promise QueryFile 提供查询名称?
- flask - 下载文件并在 Heroku - Flask 上对其进行后处理
- ssl - 恢复已删除的 kOps secret ca crt/key 文件
- javascript - 我怎样才能溢出只隐藏在一侧
- swift - swift何时/如何调用用户创建的函数
- powershell - 使用 powershell 从 OneDrive 下载 exe 文件
- python - 创建一个遍历布尔值列表的循环 - Python
- spring - spring boot(web 和 web 服务)看到 405 错误
- html - 当块内容增加时如何修复页脚滚动?
- java - POI DataFormatter 默认向下舍入 5 而不是向上舍入