1

我有一个带有自定义 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?重写有什么帮助吗?

谢谢

4

1 回答 1

0

只需剥离协议和域,保留前导斜杠。相对路径非常不适合这种情况。绝对完美的工作。

于 2014-01-31T08:06:08.307 回答