我想使用 Azure blob 文件存储来托管静态网站。
如果 html 页面位于 $web-storage 的根文件夹中,则效果很好。
但是,如果我将网页放入子文件夹中,相对链接(例如 css 文件)将不再起作用 - 因为它们被解释为基于根的链接
<link href="css/bootstrap.css" rel="stylesheet">
index.html 位于“subfolder1”中
但不是
https://blablabla.web.core.windows.net/subfolder1/css
决定
https://blablabla.web.core.windows.net/css
这是 Azure 的错误还是我的 html 中的误解/错误?
实际上,$web
是Azure通用存储V2上的一个特殊容器,其根路径如下www
对于 Apache HTTP 服务器或wwwroot
让 IIS 托管所有静态文件夹和文件。所有文件夹及其子文件夹必须在以下位置创建$web
容器。您可以在Azure门户上看到其信息,如下图所示。
![enter image description here](https://i.stack.imgur.com/nwgNs.png)
这是我创建两个文件夹的示例a
& b
和他们的index.html
under $web
Azure 存储资源管理器中的容器。
![enter image description here](https://i.stack.imgur.com/YV2Jp.png)
如果访问我的主要终点https://<account name>.z7.web.core.windows.net
,我的静态网站的索引网页是一个 Angular 示例网页,如下所示,
![enter image description here](https://i.stack.imgur.com/EmA70.png)
然后,访问子文件夹a
and b
如您所愿,这些子文件夹的索引页如下。
文件夹的index.htmla
<html>
<body>
<h2>A</h2>
</body>
</html>
![enter image description here](https://i.stack.imgur.com/dBhzx.png)
![enter image description here](https://i.stack.imgur.com/A9IaM.png)
希望它有助于理解Azure通用存储V2上的静态网站的结构。
更新您的评论:
我更新我的a/index.html
文件并添加一个新文件a/a.css
,代码如下。
a/index.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="a.css">
</head>
<body>
<h2>A</h2>
<span id='test'>Hello</span>
</body>
</html>
a/a.css
#test {
color: red;
}
有些行为取决于浏览器的实现。
问: 有什么区别http://host/a
and http://host/a/
?
答:要在 Chrome 中访问它们,这两个 url 将响应相同的内容a/index.html
。但是,它们的基本路径不同:/
for http://host/a
, but /a/
for http://host/a/
,这将导致加载相对路径资源的不同行为a.css
,如下图所示。
Fig 1.
![enter image description here](https://i.stack.imgur.com/jRttc.png)
Fig 2.
![enter image description here](https://i.stack.imgur.com/m3JX3.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)