Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

HTTP starts with two slashes. E.g.

Same goes for FTP. E.g.

However, file "URLs" start with three slashes. E.g. Reading a pdf file using chrome, the URL would be file:///D:/Desktop/Book.pdf.

Why do file URLs use three slashes?

share|improve this question
Opera for Windows expands it to file://localhost/D:/Desktop/ automatically. – user33758 Dec 27 '11 at 21:11
Also see – Pacerier Jan 23 '15 at 9:04
up vote 2 down vote accepted

As others have mentioned, the file schema is in the form "file://<host>/<path>". Though most browsers won't have a problem with only two slashes, and rightfully so.

All things being equal, the triple slash and "localhost" keyword only exist to ensure conformance with valid URI/URL syntax. In the context of the file schema, the host is meaningless since it loads directly from a filesystem without any explicit transfer protocol or server document path. Because it's not HTTP, it can't load from a standard web server where in theory you could have multiple local virtual hosts set up. And it can't load from a standard network volume that's technically another "host", since the browser just uses the volume name like "file:///volumes/foo". Finally, trying things like "file://" doesn't work. There's probably some reason for supporting an external host, but I can't think of any.

The IETF is currently drafting changes to remove the triple-slash requirement, though the draft also adds a few oddball possibilities like file:c|/path and even file://///

"3. This specification neither defines nor forbids a mechanism for accessing non-local files."

share|improve this answer

The complete syntax is file://host/path.

If the host is localhost, it can be omitted, resulting in file:///path.

See RFC 1738 – Uniform Resource Locators (URL):

A file URL takes the form:



As a special case, <host> can be the string "localhost" or the empty string; this is interpreted as 'the machine from which the URL is being interpreted'.

share|improve this answer
Cool, I'd didn't expect the answer to this question a RFC standard! – Pacerier Oct 30 '11 at 14:47
@Pacerier Almost anything that has to do with the internet can be explained by an RFC (note that they're not necessarily "standards" but may be adopted as such). – slhck Oct 30 '11 at 14:53
Note that Tim Berners Lee has apologized for those 2 slashes that are in every URL: – Peter Oct 31 '11 at 19:56
Can I omit the localhost from other protocols too or does it work only for file://? – Agos Nov 1 '11 at 11:34
Note that Firefox doesn't really follow this standard ` file://test/C:\ ` will behave the same as ` file:///C:\ ` and ` http:///test ` will give an invalid URL error – Earlz Nov 1 '11 at 15:02

Dennis has explained the 3rd slash, needed to separate the host from the path, but the other two are much more interesting...

It turns out they were a useless and somewhat arbitrary addition to the URL syntax. Tim Berners-Lee, inventor of the World Wide Web and author of many of its standards (including the RFC that Dennis linked to), lamented his usage of the 'double slash' in an interview back in 2009.

The double slash, though a programming convention at the time, turned out to not be really necessary, Mr. Berners-Lee explained. Look at all the paper and trees, he said, that could have been saved if people had not had to write or type out those slashes on paper over the years — not to mention the human labor and time spent typing those two keystrokes countless millions of times in browser address boxes.

So, save for a minor (and uncharacteristic) lapse in foresight some 18 years ago, your file URL could just have easily been file:/D:/Desktop/Book.pdf, rather than file:///D:/Desktop/Book.pdf.

There is, to answer your question, no good reason why URLs have 3 slashes.

share|improve this answer
TimBL also elaborates on this in his FAQ – Molomby Sep 25 '12 at 8:32
Not to mention that 2 bytes could be saved by just using instead of It may not seem like a lot, but they add up. Google receives millions of searches a day. How many links are on a page? At least 20. That means for a million searches, if the slashes weren't needed, 20 MB of bandwidth could have been saved. – Cole Johnson May 25 '14 at 0:23
@ColeJohnson - Did you know you can leave out the protocol part too? So could be linked to as // in a document transmitted over http. It's called a protocol relative url, all browsers support them. – Molomby Jun 13 '14 at 3:08
I am well aware of those, but I personally only use them in CSS. When writing HTML, I use the protocol also. No real reason really. Except maybe because when HTML5+CSS3 first became "big" a few years ago, almost all the sites I looked at were like that. – Cole Johnson Jun 13 '14 at 4:18
@Molomby, He is talking about all the bytes wasted when people don't do relative protocol urls. Which is like >99% of population. – Pacerier Jan 23 '15 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .