Kon*_*rad 4 html static azure azure-storage
我想使用 Azure blob 文件存储来托管静态网站。
如果 html 页面位于 $web-storage 的根文件夹中,则效果很好。
但是,如果我将网页放入子文件夹中,相对链接(例如 CSS 文件)将不再起作用 - 因为它们被解释为基于根的链接
<link href="css/bootstrap.css" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)
index.html 位于“subfolder1”中
但不是
https://blablabla.web.core.windows.net/subfolder1/css
Run Code Online (Sandbox Code Playgroud)
决定
https://blablabla.web.core.windows.net/css
Run Code Online (Sandbox Code Playgroud)
这是 Azure 的错误还是我的 html 中的误解/错误?
实际上,它是 Azure 通用存储 V2 上的一个特殊容器,它是Apache HTTP 服务器或IIS的$web根路径,用于托管所有静态文件夹和文件。所有文件夹及其子文件夹都必须在容器中创建。您可以在Azure门户上看到其信息,如下图所示。wwwwwwroot$web
以下是我在 Azure 存储资源管理器中创建两个文件夹a及其下容器b的示例。index.html$web
如果访问我的主要端点https://<account name>.z7.web.core.windows.net,我的静态网站的索引网页是一个 Angular 示例网页,如下所示,
然后,要访问子文件夹a,并且b像您想要的那样,这些子文件夹的索引页如下所示。
a<html>
<body>
<h2>A</h2>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
希望它有助于理解Azure通用存储V2上的静态网站的结构。
更新您的评论:
我更新我的a/index.html文件并添加一个新文件a/a.css,代码如下。
<html>
<head>
<link rel="stylesheet" type="text/css" href="a.css">
</head>
<body>
<h2>A</h2>
<span id='test'>Hello</span>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
#test {
color: red;
}
Run Code Online (Sandbox Code Playgroud)
有些行为取决于浏览器的实现。
http://host/a问:和 之间有什么区别http://host/a/?答:要在 Chrome 中访问它们,这两个 url 将响应来自 的相同内容a/index.html。但是,它们的基本路径不同:/for http://host/a,但是/a/for http://host/a/,这会导致加载相对路径资源的不同行为a.css,如下图所示。
图。1。
图2.