如何在 HTML 中引用相对子域? [英] How can I refer to a relative subdomain in HTML?

查看:15
本文介绍了如何在 HTML 中引用相对子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个由多个域访问的网站,例如domain1.comdomain2.com.

如果我有一个相对链接,例如 href="/wiki",那么无论我使用什么域名访问网站,该链接都会将我带到正确的位置.>

让我们说我想使用 wiki.domain1.comwiki.domain2.com,有什么方法可以建立一个相对于域名?

如果没有,当多个域指向同一服务器时,是否有一种优雅的方式来处理链接,例如上面的 wiki 链接?

解决方案

没有.您必须提供整个域.要从 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆