如何在不编写完整URL的情况下链接到当前域上的页面

时间:2012-01-29 17:58:13

标签: html url hyperlink

假设当前网址为example.com/test/example

我们想要链接到example.com/test/example/another

<a href="/another">将我链接到example.com/another

如何在不必将完整网址放入example.com/test/example/another标记的情况下关联到a

3 个答案:

答案 0 :(得分:7)

<击>

<击>
<a href="another">

应该这样做。

编辑:我的坏,实际上是:

<a href="./another">

答案 1 :(得分:3)

如果您不想使用绝对路径,我建议使用根相对路径:

<a href="/test/example/another">Link text</a>

否则,对于相对路径,itdoesntwork的答案涵盖用例。

答案 2 :(得分:-2)

您可以尝试:href="another"