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.

I was wondering why file URLs have 3 slashes in front.

For example, if I were to read a pdf file using chrome, the URL would be file:///D:/Desktop/Book.pdf.

This seems totally unnecessary. Since http uses only two slashes, common sense would tell me that a file URL should look like this: file://D:/Desktop/Book.pdf.

Why do file URLs have three slashes?

share|improve this question
Opera for Windows expands it to file://localhost/D:/Desktop/ automatically. –  screener Dec 27 '11 at 21:11
add comment

2 Answers

up vote 182 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
show 4 more comments

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
add comment

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.