Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

HTTP starts with two slashes. E.g. http://example.com.

Same goes for FTP. E.g. ftp://example.com.

However, file "URLs" start with three slahes. 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. –  screener Dec 27 '11 at 21:11
Also see stackoverflow.com/q/22772897/632951 –  Pacerier Jan 23 at 9:04

2 Answers 2

up vote 196 down vote accepted

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
@slhck thx for the info =) Btw I was wondering about this for quite some time but what's with the image @ qweop.com/x3 ? –  Pacerier Oct 30 '11 at 15:43
Note that Tim Berners Lee has apologized for those 2 slashes that are in every URL: news.bbc.co.uk/2/hi/technology/8306631.stm –  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

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 http:example.com instead of http://example.com 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 http://example.com could be linked to as //example.com 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 at 8:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.