如果这是完整的URL:
http://domain.com/dir/file.css
“绝对 URL”是指链接可以从任何网站使用。
还有这个:
../dir/file.css
相对 URL 是指链接只能从当前目录路径下访问。
这两者的组合被称为什么?
/dir/file.css
这个链接可以在该网站的任何位置可用吗?
如果这是完整的URL:
http://domain.com/dir/file.css
“绝对 URL”是指链接可以从任何网站使用。
还有这个:
../dir/file.css
相对 URL 是指链接只能从当前目录路径下访问。
这两者的组合被称为什么?
/dir/file.css
/
开头,则它是绝对路径,否则它是相对路径。你基本上在谈论一个URI方案。以你的例子为例:
/dir/file.css
这被认为是路径:
/dir/
这是文件名:
file.css
因此说“主机名属性列表路径和文件名”是一个保险的选择。或者,/dir/file.css
可以被认为是根路径,因为开头的/
将其锚定到 URL 的主机名部分。
这个来自维基百科的图表解释得很好:
foo://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose
\_/ \_______________/ \_________/ \__/ \___/ \_/ \______________________/ \__/
| | | | | | | |
| userinfo hostname port | | query fragment
| \________________________________/\_____________|____|/ \__/ \__/
| | | | | | |
| | | | | | |
scheme authority path | | interpretable as keys
name \_______________________________________________|____|/ \____/ \_____/
| | | | | |
| hierarchical part | | interpretable as values
| | |
| path interpretable as filename |
| ___________|____________ |
/ \ / \ |
urn:example:animal:ferret:nose interpretable as extension
path
_________|________
scheme / \
name userinfo hostname query
_|__ ___|__ ____|____ _____|_____
/ \ / \ / \ / \
mailto:username@example.com?subject=Topic
/dir/file.css
可以被认为是根路径。但这也取决于上下文。因此上下文也很关键。 - Giacomo1968