为什么 http://在浏览器导航栏中包含两个斜杠和 file:///三个? [英] Why does http:// contain two slashes and file:/// three in a browser navigation bar?
问题描述
为什么 http://
包含两个斜杠——这只是一个 URL 的标准,还是有任何逻辑意义?为什么 file:///
包含三个斜杠,如 file:///C:/a.html
?
Why does http://
contain two slashes—is that just a standard for a URL, or does it have any logical meaning? And why does file:///
contain three slashes, as in file:///C:/a.html
?
推荐答案
权限组件前面有一个双斜线(//")[…]
The authority component is preceded by a double slash ("//") […]
这也是为什么并非所有 URI 都包含双斜杠:因为并非所有 URI 都具有权限组件(例如,使用 mailto
方案、xmpp
方案等的 URI).
This is also why not all URIs contain the double slash: because not all URIs have an authority component (e.g., URIs using the mailto
scheme, the xmpp
scheme, etc.).
如果您想知道为什么为 (HTTP) URI 选择双斜杠而不是其他东西(或什么都不做),请参阅 Tim Berners-Lee 的常见问题解答 为什么是//、# 等? → //的历史是什么?
If you wonder why the double slash instead of something else (or nothing) was chosen for (HTTP) URIs, see Tim Berners-Lee’s FAQ Why the //, #, etc? → What is the history of the //?
tl;dr:他复制了 Apollo 使用的文件名语法.
tl;dr: He copied the filename syntax which Apollo used.
顺便说一句,他后悔那个选择:
By the way, he regrets that choice:
我不得不说,现在我很遗憾语法如此笨拙.我希望 http://www.example.com/foo/bar/baz
被写成 http:com/example/foo/bar/baz
在客户端会发现 www.example.com
存在并且是要联系的服务器.但现在已经晚了.
I have to say that now I regret that the syntax is so clumsy. I would like
http://www.example.com/foo/bar/baz
to be just writtenhttp:com/example/foo/bar/baz
where the client would figure out thatwww.example.com
existed and was the server to contact. But it is too late now.
这篇关于为什么 http://在浏览器导航栏中包含两个斜杠和 file:///三个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!