How to go up one sub-domain in a relative URL?

2019-02-28 12:32发布

问题:

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?

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.

回答1:

That is not possible.

To address your second concern, use a protocol-relative URL:

src="//dessert.mysite.com/images/bg.gif"


标签: url uri