Vincent Cantin
Vincent Cantin

Reputation: 17292

The "//" in "http://"

I would like to know why designers of the URI standard chose to have // in the definition of URIs like http://.

Why make it so complex? Why not just use http:?

Upvotes: 11

Views: 413

Answers (2)

Simeon Visser
Simeon Visser

Reputation: 122496

Here's the answer (The Web’s Inventor Regrets One Small Thing).

In hindsight Tim Berners-Lee would remove it as well.

The reason it was included:

The double slash, though a programming convention at the time, turned out to not be really necessary.

Upvotes: 30

James Manning
James Manning

Reputation: 13589

RFC 2396 covers this, FWIW.

http://www.ietf.org/rfc/rfc2396.txt

The pseudocode in part 7 of section 5.2 in particular best answers your question, that the "//" is there to denote that what follows it is the authority part of the URI (since the pseudocode also makes it clear that it's not a required part of the URI).

if authority is defined then
         append "//" to result
         append authority to result

In addition, it's spelled out a bit more in RFC 3986 section 3.

When authority is not present, the path cannot begin with two slash characters ("//"). These restrictions result in five different ABNF rules for a path (Section 3.3), only one of which will match any given URI reference.

Upvotes: 10

Related Questions