如何在相对 URL 中上升一个子域? [英] How to go up one sub-domain in a relative URL?
问题描述
从 cupcakes.dessert.mysite.com/
上的页面,我如何使用相对 URL 访问 dessert.mysite.com/
中的图像或样式表代码>?有没有办法在 URI 中指定返回一个子域"?
From a page at cupcakes.dessert.mysite.com/
, how can I use a relative URL to access images or a style-sheet from dessert.mysite.com/
? Is there a way to specify "back one sub-domain" in URIs?
我不想使用绝对 URL,例如 src="http://dessert.mysite.com/images/bg.gif"
因为这种方法需要不同的绝对 URL对于 salad.mysite.com
,以及可能覆盖 HTTPS 连接.
I don't want to use an absolute URL such as src="http://dessert.mysite.com/images/bg.gif"
because that approach would require a different absolute URL for salad.mysite.com
, as well as possibly overriding an HTTPS connection.
推荐答案
那是不可能的.
要解决您的第二个问题,请使用协议相对 URL:
To address your second concern, use a protocol-relative URL:
src="//dessert.mysite.com/images/bg.gif"
这篇关于如何在相对 URL 中上升一个子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!