URI vs. URL: What’s the Difference?

Updated (1/18/2011) : Because there’s still a lot of confusion, I’ve created a third post that attempts to resolve a lot of the questions from the comments on the last two posts. The new post is here.

Updated (8/27/2009): I’ve created another post that attempts to make the distinctions a bit more clear. The new post is here.

What is the difference between a URL and URI and why does it matter? This topic is confusing to some (myself included) and I thought I’d share my understanding of the two concepts. I’m hoping this post will give you a better understanding about how the two differ and why it matters to some.

Note: The goal of this post is to simplify the distinction between URI and URI. If you feel that in the summarization process something was lost, or it’s simply just correct, please post a comment and the information will be corrected. I only ask for any comments/criticism to be constructive.

Update: Thanks some constructive, and not-so constructive, feedback from some readers I have updated this post to correct many of my own misunderstandings. Of which, there were many.

URI

A URI identifies a resource either by location, or a name, or both. More often than not, most of us use URIs that defines a location to a resource. The fact that a URI can identify a resources by both name and location has lead to a lot of the confusion in my opionion. A URI has two specializations known as URL and URN.

URN

A URI identifies a resource by name in a given namespace but not define how the resource maybe obtained. This type of URI is called a URN. You may see URNs used in XML Schema documents to define a namespace, usually using a syntax such as:

<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:example"

Here the targetNamespace use a URN. It defines an identifier to the namespace, but it does not define a location.

URL

A URL is a specialization of URI that defines the network location of a specific resource. Unlike a URN, the URL defines how the resource can be obtained. We use URLs every day in the form of http://damnhandy.com, etc. But a URL doesn’t have to be an HTTP URL, it can be ftp://damnhandy.com, smb://damnhandy.com, etc.

The Difference Between Them

So what is the difference between URI and URL? It’s not as clear cut as I would like, but here’s my stab at it:

A URI is an identifier for some resource, but a URL gives you specific information as to obtain that resource. A URI is a URL and as one commenter pointed out, it is now considered incorrect to use URL when describing applications. Generally, if the URL describes both the location and name of a resource, the term to use is URI. Since this is generally the case most of us encounter everyday, URI is the correct term.

72 thoughts on “URI vs. URL: What’s the Difference?

  1. Pingback: URL, URI & URN.. cakewalk? Not for me atleast.. | Super Compiler

  2. Pingback: johnny writes « URL vs URI «

  3. Pingback: Introducing onedb: Connect Small Data in the Cloud « Missing Link

  4. Pingback: URI Increment (javascript) | ToddTheGeek.com

  5. [quote]Can we say that:”http://www.domain.tld/somepath/file.php?mykey=somevalue”is an URI and that the “http://www.domain.tld/somepath/file.php” part is an URL?[/quote]No, both are URLs.

    Like

    • No, that’s incorrect: the URL does not need to include the extension. Both URIs are dereferencable via HTTP and will return some type of response. The file extension only indicates what type you might get, but it is not a guarantee. Think of it this way:

      The URI is a unique identifier that is more like an interface or abstract class. You can’t instantiate it and thus you have to use specialization such as a URN or URL.

      The URN is also unique identifier that is not dereferencable and is only used as a means to identify a resource. A URN is a URI.

      The URL is again a unique identifier that is dereferencable over some type of network protocol and is also used as a means to identify a resource. A URL is a URI.

      Liked by 1 person

    • No, that’s incorrect: the URL does not need to include the extension. Both URIs are dereferencable via HTTP and will return some type of response. The file extension only indicates what type you might get, but it is not a guarantee. Think of it this way:

      The URI is a unique identifier that is more like an interface or abstract class. You can’t instantiate it and thus you have to use specialization such as a URN or URL.

      The URN is also unique identifier that is not dereferencable and is only used as a means to identify a resource. A URN is a URI.

      The URL is again a unique identifier that is dereferencable over some type of network protocol and is also used as a means to identify a resource. A URL is a URI.

      Like

  6. All URL’s are URI’s. URI’s are more general and include relative addresses. It is incorrect to say “relative URL” because there is no such thing. A URL must include protocol(http, http://ftp...), host name or IP, and a path to the resource. A URI can be any absolute or relative path.

    URL: http://www.lonedogpoems.com
    URL: http://www.lonedogpoems.com/index.php
    not URL: index.php
    not URL: ..
    The last two are not URL’s but they are still URI’s.

    Like

  7. All URL’s are URI’s. URI’s are more general and include relative addresses. It is incorrect to say “relative URL” because there is no such thing. A URL must include protocol(http, http://ftp...), host name or IP, and a path to the resource. A URI can be any absolute or relative path.

    URL: http://www.lonedogpoems.com
    URL: http://www.lonedogpoems.com/index.php
    not URL: index.php
    not URL: ..
    The last two are not URL’s but they are still URI’s.

    Like

  8. @Jordan Tucker
    To clarify further: the presence of a query string does not distinguish a URL from a URI. The key difference are between URL and URN, where a URL declares a unique location from the content can be retrieved where a s URN is merely a name. However, BOTH schemes are considered URIs.

    @Seeker
    You are a 100% correct: URL and URNs are specialisations of a URI.

    This conversation gets a lot more fun when you starting thinking about IRIs 😉

    Ryan-

    Like

  9. @Jordan Tucker
    To clarify further: the presence of a query string does not distinguish a URL from a URI. The key difference are between URL and URN, where a URL declares a unique location from the content can be retrieved where a s URN is merely a name. However, BOTH schemes are considered URIs.

    @Seeker
    You are a 100% correct: URL and URNs are specialisations of a URI.

    This conversation gets a lot more fun when you starting thinking about IRIs 😉

    Ryan-

    Like

  10. Jordan Tucker :
    However, this has changed so that a URN is a URI that has the “urn” scheme, and a URL is an abstract term that describes a URI that identifies a resource by its location. Therefore, URLs and URNs are both URIs.

    URI is an abstract concept, URL and URN are concrete implementations of a URI.

    Like

  11. Jordan Tucker :
    However, this has changed so that a URN is a URI that has the “urn” scheme, and a URL is an abstract term that describes a URI that identifies a resource by its location. Therefore, URLs and URNs are both URIs.

    URI is an abstract concept, URL and URN are concrete implementations of a URI.

    Like

  12. @Giacomo Masetti
    “http://www.domain.tld/somepath/file.php?mykey=somevalue” is a URI. It’s also a URL because it identifies a resource by its location. “http://www.domain.tld/somepath/file.php” is also a URL and a URI. The difference between the two URIs is that the second lacks a query string.

    Like

Comments are closed.