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 slashe
The authority component of a URI has to be preceded by //
:
The authority component is preceded by a double slash ("//") […]
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.).
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: He copied the filename syntax which Apollo used.
By the way, he regrets that choice:
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.