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
?

- 55
- 5
-
2[superuser.com: Why do file URLs start with 3 slashes?](http://superuser.com/questions/352133/why-do-file-urls-start-with-3-slashes) – CBroe Apr 05 '16 at 17:44
-
Is "[Because Tim Berners-Lee told you to](https://tools.ietf.org/html/rfc3986)" an acceptable reason? – Jongware Apr 05 '16 at 17:45
2 Answers
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.
-
3Might be some regret, but it does make it easier to at a glance isolate the domain from the protocol, in my opinion – jjxtra Nov 25 '19 at 01:33
As mentioned in this superuser post:
The complete syntax is file://host/path.
If the host is localhost, it can be omitted, resulting in file:///path.
In other words, referring to files in your computer is just like referring to files in localhost.
-
then why `http://` contains two slashes or what does mean of first two slashes in `file://` too? – Apr 05 '16 at 17:49
-
1From the following [Wikipedia: File_URI_Scheme](https://en.wikipedia.org/wiki/File_URI_scheme) , it is explained that it is in the following format: `file://
/ – Kraang Prime Apr 05 '16 at 17:51`, if the ` ` portion is left blank, the other `/` following it needs to remain thus `file:///` is the same as `file://localhost/` . Most browser url's are in the format of ` :// / ` -
@SanuelJackson why everyone is repeating same words? I'm asking what does mean of first two slashes? `file://` or `http://`? – Apr 05 '16 at 17:53
-
3@LetDoit - those are the characters chosen as the designated separator when drafting the rfc for uri format. A uri can also contain other data such as username and password : `
:// – Kraang Prime Apr 05 '16 at 18:20: @ : / ` is a more "complete" example. If you notice there are more than one method where `:` would appear before a `/` so I imagine that would be why they denoted `//` following the first `:` to make it easier to parse. Generally though, the concept is what the original author of the rfc decided on. Similarly, spintax uses `{ | }` as that was their choice.