【发布时间】:2014-02-23 11:21:53
【问题描述】:
我有一个带有自定义 503 的 nginx。
error_page 503 @maintenance;
location @maintenance {
root /usr/share/nginx/html/custom/503;
rewrite ^(.*)$ /index.html break;
}
location /503-static/ {
root /usr/share/nginx/html/custom/;
}
我的 /503/index.html 是我的自定义维护页面,其中包含漂亮的 CSS 和照片:
<link rel="stylesheet" type="text/css" href="https://www.mydomain.tld/503-static/maintenance.css">
所有这些都工作正常。
问题是我想用 503-static/maintenance.css 之类的相对链接替换 css 链接。
如果用户请求:www.mydomain.tld 自定义 html 将被加载,并且带有相对路径的 maintenance.css 也会被加载
但是:如果用户请求:www.mydomain.tld/a/b/c/bla.html,我的自定义 503 索引 html 将被正常加载,但 css 的相对链接将是 $document_root/a/b /c/503-static/maintenance.css ....不会显示
我的问题是:使用 css 文件的相对链接路径...如何应对不同的 $uri?重写有什么帮助吗?
谢谢
【问题讨论】:
标签: nginx rewrite maintenance http-status-code-503