URL, URI, and URN

There are two types of URIs: URLs and URNs. Here's a brief summary and hints about when to use which.

Dino Esposito

December 18, 2000

3 Min Read
ITPro Today logo in a gray background | ITPro Today

We use URLs so frequently that it's easy to find people who think URL is a proper noun rather than an acronym. URL stands for Uniform Resource Locator. HTTP, which you regularly use to connect to remote sites, requires that the target machine you want to talk to be univocally identified through a name. Behind the URL is a syntax that mandates the following format:

://  [:] [ [? ]]
  • is the name of the protocol used to access the resource. The resource isn't necessarily a remote resource and the protocol isn't necessarily HTTP. For example, both the following URLs are perfectly legitimate:

http://www.wintellect.comfile://c:winntsystem32shell.dll
  • represents the IP address of the server.

  • is the number of the TCP port where the conversation takes place. The port attribute defaults to 80, which is the port where systems usually exchange HTTP handshakes and packets. The following is another perfectly legitimate URL:

    http://www.wintellect.com:80
  • and are other parameters that let you specify a path within the host machine and some arguments to direct the system to locate a specific document.

Of all this syntax, only the host parameter is mandatory. The path portion of the string usually has a protocol-specific format.

All this sounds so familiar that we sometimes forget that there's more. A URL is nothing more than a special instance of a slightly more general mechanism for identifying resources over the Web. This basic mechanism is the Uniform Resource Identifier (URI). By definition, a URI is a formatted string that univocally and uniquely identifies a resource. There are two types of URIs: URLs and Uniform Resource Names (URNs). URNs identify XML schemas. The URN syntax is as follows:

urn::
  • is the namespace identifier.

  • is a namespace-specific string.

For example,

urn:schemas-microsoft-com:rowset

is the URN that defines an ADO recordset.

Basically, you have two flavors of identifiers for Web resources: address-specific (URL) and name-based (URN). URLs contain the underlying protocol you need to use to access the specified resource. URLs, therefore, encode the physical path to the resource and identify that path through a location. By contrast, a URN is location-independent and has no notion of the protocol you might use to access a specified resource. In other words, the resource is only a name—a unique name.

Roughly speaking, the difference between URLs and URNs is the difference between a person's social security number and his or her name. The social security ID lets you know instantaneously all available information about a person. Not only do you unequivocally identify the person, but you also have the key to access all the data he or she represents. When you use a name, you have only a unique name that doesn't always give you the key to access the right information.

A URL takes you straight to the resource and the data. A URN is only a unique name you can use to identify any resource you want. URNs are related to namespaces. Both URLs and URNs can uniquely identify resources over the Web. Use URLs when you need to know or specify location information. Use URNs if the resource is location-independent.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like