<a href>将链接附加到当前 url 的末尾 [英] <a href> appends link to end of current url
问题描述
当我将带有 <a href="">
标签的 HTML 文件上传到我的网站时,该链接会将链接中的 URL 附加到当前 URL 的末尾.
When I upload an HTML file to my website with <a href="">
tags, the link appends the URL in the link to the end of the current URL.
例如,如果我的网站是 example.com
并且 index.html 文件被放置在 example.com/test
并且链接是 google.com
然后链接将转到 example.com/test/google.com
.
For example, if my website was example.com
and the index.html file was placed in example.com/test
and the link was google.com
then the link would go to example.com/test/google.com
.
如何使链接转到 google.com
?
推荐答案
您应该真正了解绝对路径和相对路径.您使用的是相对路径.
You should really learn about absolute and relative paths. What you're using is a relative path.
这是您服务器上的绝对路径:
This is an absolute path on your server:
<img src="/images/logo.png">
这是一个带有 http 协议的网址 - 打开 Google.com
This is an url with http protocol - opens Google.com
<a href="http://google.com">Google</a>
这是一个没有明确协议的url,它会根据你的页面使用的内容变成http或https:
This is an url without explicit protocol, it will turn into http or https based on what your page uses:
<a href="//google.com">Google</a>
使用其中一种来满足您的需要(通常是 http 一种).
Use one of those for what you need (typically the http one).
这篇关于<a href>将链接附加到当前 url 的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!