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.

Be Sociable, Share!
    URI vs. URL: What’s the Difference?
    • Marcus

      I’m not sure if you’ll find it constructive to say this, but this post is quite misleading. The first time I saw it I just ignored it, but since someone else linked to you, I have to say that a URL is a deprecated term for a URI that includes the network location and scheme. A URI is much more flexible.

      So to break it down:

      1. URI vs URL doesn’t have anything to do with extensions representing mime types nor content negotiation

      2. It’s never preferred to use the term URL in a modern technical application because the term is deprecated, it is only appropriate in colloquial use, where “URL” still rules

      3. Content negotiation lives within the world of HTTP (in the context of your article), addressing lives within the world of URIs, the HTTP scheme happens to use URI’s “generic syntax” for resource identifiers. This is not a HTTP-specific syntax by any means

      4. A URL with or without an extension would be just as right either way, it lives in a different world from HTTP content negotiation

      I guess the really important thing is that it’s just not appropriate to use the term URL in a modern technical context at all. The term has no meaning or importance technically, only culturally. One could argue that in a colloquial sense, URI and URL mean exactly the same thing.

      To read Tim Berners-Lee on the topic:

      “A URI can be further classified as a locator, a name, or both. The term “Uniform Resource Locator” (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network “location”).”

      From Uniform Resource Identifier (URI): Generic Syntax, http://gbiv.com/protocols/uri/rfc/rfc3986.html#URLvsURN)

    • maht

      What a complete load of nonsense. The file extension is utterly meaningless. It contains NO information used by the HTML client for anything. It is a convenience for human operators reading URIs not machines.

      A Universal Resource Locator is a kind of Uniform Resource Identifiers. A URI is part of TCP/IP, a URL is the URI type specific to HTTP.

    • Pingback: Javascript News » Blog Archive » URI vs. URL: What’s the difference?()

    • Len

      I’ve always believed the URL referred to the full web address including hostname, and/or path, and/or file. The URI on the other hand would cover all the relative use cases inside an html page, where further links are referenced with no hostname and just path and/or file.

      Whatever my understanding was, if URL is deprecated now thats fine with me. Inconsistencies like this one aren’t entirely helpful though towards moving users to new web standard proposals. Another small example is validators that go ballistic looking for doctype, and complaining about tags being in uppercase when actually thats how the original standards suggested coding pages.

    • http://damnhandy.com Ryan

      Actually Marcus, your comments where very helpful and constructive. After taking a deeper look at things, your comments were spot on and I have updated this post to more accurately reflect the correct differences. In fact, this was the type of feedback I was looking for, so thanks for taking the time to post your feedback!

      Ryan-

    • Pingback: DamnHandy : » URI vs. URL Post Corrected()

    • Kam

      This post would be much more informative if examples were given, particularly showing the differences between a URL and URI.

    • Marcus

      Nice, Ryan. I’m glad that for once in my life I ratcheted down my emotion in a blog comment to a useful level, heh. Wish I could say that more often ;-)

    • http://damnhandy.com Ryan

      Marcus, if more folks could leave level-headed and technically correct comments such as yours, the web would a much better place :)

    • Pingback: User First Web » links for 2007-11-26()

    • http://www.jondavis.net/ Jon Davis

      Marcus, URL is NOT deprecated. That’s like saying “XHTML is deprecated and we should now refer to it as XML”. “URI” has been around for as long as I can remember (I’ve been in this for at least a decade, even submitted a few IETF proposals and got shot down because my proposals “were not URI-compliant”), URI has never tried to replace “URL”, which is a [locator] subset of URI [identifier].

      In practice, you shouldn’t call it “URI” if you’re just referring to an or . You should call it “URI” if you’re referring to a schema namespace identifier or, in some cases, a versioned Javscript library. I set up a web resource specifically for that purpose at cachefile.net.

    • http://www.jondavis.net/ Jon Davis

      eww. my comment got truncated and turned blood-red.

      ehh, you shouldn’t call it “URI” if you’re just referring to an [img src=”..”] or [a href=”..”]. That’s a URL. You should call it “URI” if you’re referring to a schema namespace identifier, or, in some cases, a versioned Javscript library in [script src=”..”. I set up a web site specifically for that purpose at cachefile.net.

    • Pingback: Mobile Hippie | links for 2007-11-27()

    • Pingback: Unterschied zwischen URL und URI » Word Up!()

    • Pingback: SiNi Daily » Blog Archive » URI vs. URL: What’s the difference?()

    • http://lankatechblog.blogspot.com/ Thiwanka

      Blog is Correct.
      Uniform Resource Identifier (URI), is a compact string of characters used to identify or name a resource. The main purpose of this identification is to enable interaction with representations of the resource over a network, typically the World Wide Web, using specific protocols. URIs are defined in schemes defining a specific syntax and associated protocols.

      URI can be classified as a locator or a name or both. A Uniform Resource Locator (URL) is a URI that, in addition to identifying a resource, provides means of acting upon or obtaining a representation of the resource by describing its primary access mechanism or network “location”. For example, the URL http://www.wikipedia.org/ is a URI that identifies a resource (Wikipedia’s home page) and implies that a representation of that resource (such as the home page’s current HTML code, as encoded characters) is obtainable via HTTP from a network host named http://www.wikipedia.org. A Uniform Resource Name (URN) is a URI that identifies a resource by name in a particular namespace. A URN can be used to talk about a resource without implying its location or how to dereference it. For example, the URN urn:isbn:0-395-36341-1 is a URI that, like an International Standard Book Number (ISBN), allows one to talk about a book, but doesn’t suggest where and how to obtain an actual copy of it.

    • http://musheaven.com Fergie

      In comments form I often see field name “URI”, but its field just for website’s url. Is it just logic error or what?

    • http://www.cathetel.com Angel

      To think we have lived all these years without knowing that there was a URI and that it was significant.

    • Alex

      To my understanding;

      A Uniform Resource Indicator identifies a resource (e.g. HTML page)

      A Uniform Resource Locator specifies how to access the resource (e.g via HTTP)

    • Red2

      If two examples were given one for URI and one for URL, and just tell how they differe, it would be much more helpful, and much more concise than what is given here. Honestly, I couldn’t understand much other than “a uri is a url” … (or is it the other way round? :-))

    • Jason

      I guess the W3C has deprecated the term ‘URL’. I have not actually read that on their site, but I have heard it enough times from other people to believe it.

      If you want to use the term ‘URI’ instead of ‘URL’, that’s fine, but in order to make it technically correct (which is what this seems to be all about) the meaning of the ‘URI’ needs to be changed so that a URN is not a URI.

      Otherwise, to take an example from Thiwanka, if a form asks you for a URI and you enter ‘urn:isbn:0-395-36341-1′, you’re technically correct, but the form is gonna fall on it’s face trying to understand it.

      I think the W3C is wrong here, and I will continue to use URL when I want a URL, URN when I want a URN, and URI when I want either one.

    • dihymo

      Actually, the W3C is wrong to have deprecated the term URL. The distinction matters. Also a URN is most definitely a URI.

      A URL: The house at 123 Some Street Anytown, CA 12345, by invitation only
      A URN: John’s house.

      We could define something called a URA, uniform resource accessor, but we already have a name for them: Protocol. Since we only use one standard for defining and searching namespaces, the protocol for a namespace is implied and never mentioned. Instead we include the containing namespace. On the other hand there are many methods for accessing information so to acquire a document one has to include the protocol.

      Some might argue that protocols and namespaces are both URAs.

    • alasdair.fraser

      All URLs are URIs then, and it seems is if the concept of URI is a refinement of URL, to cater for the increased range of resources that are being made available via the internet, So, simple question –
      “As a plain user, doesn’t program (doesn’t want to program) but just likes to understand things; would I ever need to know the difference between URL and URI?”

    • I Wonder

      “it seems is if the concept of URI is a refinement of URL”

      Hm, it seems the opposite. A URL contains everything a URI does, but extends it with location and access info.

    • Pritesh

      Best solution –

      Jon Davis Says:

      November 26th, 2007 at 4:49 pm
      Marcus, URL is NOT deprecated. That’s like saying “XHTML is deprecated and we should now refer to it as XML”. “URI” has been around for as long as I can remember (I’ve been in this for at least a decade, even submitted a few IETF proposals and got shot down because my proposals “were not URI-compliant”), URI has never tried to replace “URL”, which is a [locator] subset of URI [identifier].

      In practice, you shouldn’t call it “URI” if you’re just referring to an or . You should call it “URI” if you’re referring to a schema namespace identifier or, in some cases, a versioned Javscript library. I set up a web resource specifically for that purpose at cachefile.net.

    • Pingback: Reality Me » URL Shorteners Causing a Stir()

    • http://www.vanylla.it Giacomo Masetti

      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?

    • http://damnhandy.com Ryan

      You can say that they are both a URI and a URL. Again, a URL is basically a sub-class of URI.

    • Jordan Tucker

      Classically, URIs were grouped into two subclasses: a location (URL) or a name (URN). Each scheme was put into one of these subclasses; http into the URL subclass, isbn into the URN subclass.

      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.

      There’s nothing wrong with using the term URL so long as you know that URL and URI are not interchangeable.

    • Jordan Tucker

      @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.

    • http://damnhandy.com Ryan

      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.

    • Seeker

      If you need some examples of URNs there is plenty of them on Wikipedia:
      http://en.wikipedia.org/wiki/Uniform_Resource_Name#Examples

      Anyone interested should also look at:
      http://en.wikipedia.org/wiki/URI_scheme
      http://en.wikipedia.org/wiki/URI

    • Seeker

      @Giacomo Masetti
      Both of them are URLs. URL to URI is like a square to rectangle – every square is a rectangle, but only specyfic rectangles are squares.

    • http://damnhandy.com Ryan

      @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-

    • Josh

      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.

    • http://www.damnhandy.com/2007/11/19/uri-vs-url-whats-the-difference/ hina

      URI is whole address of a resource but resource extension is not mentioned. in URL we also mention the extension.
      for example:

      URI: http://www.abc/home
      URL: http://www.abc/home.html

    • http://damnhandy.com Ryan

      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.

    • http://twitter.com/eordano Esteban Ordano

      [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.

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

    • Pingback: Introducing onedb: Connect Small Data in the Cloud « Missing Link()

    • Pingback: johnny writes « URL vs URI «()

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

    • Pingback: ???? ???? URL??? ??? ?? ??? | jpstory.net()

    • Pingback: Firefox adres çubu?unu daha da kullan??l? hale getirin()