我怎样才能在HTML中引用相对的子域? [英] How can I refer to a relative subdomain in HTML?
问题描述
domain1.com
和 domain2.com
。 如果我有一个相对的链接,比如 href =/ wiki
,那么无论我通过哪个域名访问该网站,该链接都会将我带到正确的位置。
可以说我想用 wiki.domain1.com
和 wiki.domain2 .com
,是否有某种方式可以使这个相对于域名的链接?
如果没有,是否有一个优雅的方式当多个域指向同一个服务器时,如何处理上面的维基链接等链接? 解决方案
你必须给整个域。要从 domain1.com
链接到 wiki.domain1.com
,链接必须看起来像 href =http://wiki.domain1.com
。
Let's say I have a website which is accessed by multiple domains, e.g. domain1.com
and domain2.com
.
If I have a relative link, such as href="/wiki"
, then no matter what domain name I access the website by, that link will take me to the correct place.
Lets say instead I wanted to use wiki.domain1.com
and wiki.domain2.com
, is there some way I can make a link to this relative to the domain name?
If not, is there an elegant way to handle a link such as the wiki link above when multiple domains point to the same server?
No. You'll have to give the whole domain. To link from domain1.com
to wiki.domain1.com
, the link has to look like href="http://wiki.domain1.com"
.
这篇关于我怎样才能在HTML中引用相对的子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!