关于链接的一般问题
我觉得问这个问题有点愚蠢,但是...:)
如果我是某个网站的访问者(比如说“www.site.com”),并且我目前在这个页面“www.site.com”上/pageX”,然后我打开该页面的源代码,我会找到一些“”标签。如果这些标签具有类似 href="/pageY/.content.html" 的 href,我如何判断(无需单击该链接,或查看链接完整地址)链接是否指向“www.site.com/pageY/content.html”。 html”或“www.site.com/pageX/PageY/content.html”?
我希望这个问题不会太令人困惑:)
I feel i little bit stupid to ask this, but... :)
If i'm visitor of some website (let's say "www.site.com"), and i'm currently on this page "www.site.com/pageX" and I open that page's source, i'll find some "<A>
" tags. If those tags have hrefs like this href="/pageY/.content.html" how can I tell (without clicking that link, or looking at links full address) if link points to "www.site.com/pageY/content.html" OR "www.site.com/pageX/PageY/content.html"?
I hope this question is not too confusing :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当 URL 以斜杠 / 开头时,它会从站点的根目录开始。因此 href="/pageY/content.html" 将指向 www.site.com/pageY/content.html。而 href="pageY/content.html" 则指向当前位置:www.site.com/pageX/pageY/content.html。
When the URL starts with a slash / then it starts from the root of the site. So href="/pageY/content.html" will point to www.site.com/pageY/content.html. While href="pageY/content.html" points to the current location so: www.site.com/pageX/pageY/content.html.
如果您看到
链接文本
,则该链接链接到具有相同 URL 的当前页面。您还经常在表单中看到将 POST 数据发布到同一 URL。 :)If you see
<a href="">Text of link</a>
then that link links to the current page with the same URL. You also see that often in forms to post the POST-data to the same URL. :)您可以看出,因为该链接以
/
开头,这意味着它将相对于站点根目录。您可以在这里阅读更多相关信息:http://www.motive.co.nz /glossary/linking.php#root
You can tell because that link starts with a
/
which means it will be relative to the site root.You can read more about this here: http://www.motive.co.nz/glossary/linking.php#root
不确定我是否正确理解了这个问题,但会尝试解释。
URL 有相对 URL 和绝对 URL。相对 URL 类似于
content.html
或./content.html
。绝对 URL 以/
开头,例如/pageX/content.html
。相对 URL 将附加到基本 href,即您所在的目录(
www.site.com/pageX
表示www.site.com/pageX/index.html)。可以使用
元素更改基本 href。当您访问www.site.com/pageX
时访问content.html
会将您引导至www.site.com/pageX/content.html.
绝对 URL 始终将 URL 附加到域中。当您访问
www.site.com/pageX
时访问/content.html
会将您引导至www.site.com/content.html
。不知道这是否回答了你的问题。
Not sure I understand the question correctly, but will try to explain.
There are relative and absolute URL's. Relative URL's look like
content.html
or./content.html
. Absolute URL's start with an/
, like/pageX/content.html
.Relative URL's will be appended to the base href, which is the directory you're in (
www.site.com/pageX
forwww.site.com/pageX/index.html
). The base href can be changed with the<base/>
element. Visitingcontent.html
when you're onwww.site.com/pageX
would lead you towww.site.com/pageX/content.html
.Absolute URL's will always append the URL to the domain. Visiting
/content.html
when you're onwww.site.com/pageX
would lead you towww.site.com/content.html
.Don't know if that answered your question though.