What are URI, URL, and URN?

Understand the difference between URI, URL, and URN with clear examples and real-world applications. Learn more

Ceyhun Enki Aksan
Ceyhun Enki Aksan Entrepreneur, Maker

Routing (URL Matching/Redirect) discusses the routing process and provides an example implementation.

Given the several questions received regarding the URI and URL expressions mentioned in the article, an additional piece of content explaining their equivalents will be appropriate.

URI (Uniform Resource Identifier)

URI (Uniform Resource Identifier) is a character string that serves as a precise identifier for a resource (such as a document, image, file, etc.) and follows a standardized format for such identification. URIs are subtypes within the URL scope. For example, a page, an image, or a file could be represented as a URI; such as http://examplewebsite.com/logo.png, or ISBN 0-486-27557-4. URI encompasses two categories: URL and URN. Both URNs (names) and URLs (locators) are considered URIs, and a specific URI can simultaneously serve as both an identifier and a locator.

URL (Uniform Resource Locator)

URL (Uniform Resource Locator) can also be referred to as a Uniform Resource Locator or a Resource Locator. The location of resources accessible via the Internet (such as files, documents, etc.) is specified using a URL. Technically, a URL forms the initial portion of a URI. Structurally, a URL is followed by a URN. However, when a location is specified, the URL expression is typically used instead of a URI. The syntax of a URI is as follows:

  • scheme://domain:port/path?query_string#fragment_id
  • scheme://user:password@host:port/path?query_string#fragment_id

A URL specifies both where a resource is located and how to access it. It can support many protocols such as http:// and ftp://. When illustrating the relationship between URL and URN through an address specification, a URL identifies a location, while a URN identifies the name of the resource at that location. For example, telnet://192.0.2.16:80/ is a URL, whereas tel:+1-816-555-1212 is a URN.

A source is uniquely and permanently identified by a name, but it is not necessary to specify how one can find it on the Internet. Beyond merely defining documents, URNs can also define concepts and ideas. A URN typically begins with the urn: prefix.

  • urn:isbn:0451450523 refers to a book by ISBN.
  • urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66 is a globally unique identifier.
  • urn:publishing:book is an XML namespace that defines a document as a book.

Further Reading