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?

link|improve this question

Opera for Windows expands it to file://localhost/D:/Desktop/ automatically. – screener Dec 27 '11 at 21:11
feedback

1 Answer

up vote 149 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:

file://<host>/<path>

[…]

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'.

link|improve this answer
3  
Cool, I'd didn't expect the answer to this question a RFC standard! – Pacerier Oct 30 '11 at 14:47
17  
@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
2  
@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
2  
Perhaps someone should write a blog post about this, explaining how this stuff works in more detail? – Ivo Flipse Oct 31 '11 at 6:17
3  
Can I omit the localhost from other protocols too or does it work only for file://? – Agos Nov 1 '11 at 11:34
show 3 more comments
feedback

Your Answer

 
or
required, but never shown

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