News for hackers. Stuff that matters.
Re:Ask HN: Why does a url use ://? by jacquesm on Monday August 31, 2009 @02:46PM (#796465)
The ':' is to separate the scheme from the bits that are specific to the scheme. The // is to indicate a hostname and not a directory. http:/test is a valid url indicating a relative path on the machine that the current resource came from, http://test is a url that specifies a resource on a machine mapped to the TLD test. The double slash removes the ambiguity. It really is two bits, a ':' and the '//'

Other possible sources of confusion:

http://test.com:80/

You could then get:

http:/test.com:/

Position would give it away, but, if you then complicate matters further by using default protocol (in your broweser http) it looks like:

:/test.com:/

In many browsers

://test.com:/ is perfectly legal.

Of course, you could strip that down further by dropping the default port colon to get:

://test.com/

See here for a much longer (and probably better :) ) explanation:

http://tools.ietf.org/html/rfc1738

I hope that helps !

There are no comments on this comment yet.