By Sean McMains


2008-10-06 21:26:58 8 Comments

People talk about URLs, URIs and URNs as if they're different things, but they look the same to the naked eye.

What are the distinguishable differences between them?

30 comments

@Stephen Ostermiller 2015-03-04 21:51:14

URI -- Uniform Resource Identifier

URIs are a standard for identifying documents using a short string of numbers, letters, and symbols. They are defined by RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax. URLs, URNs, and URCs are all types of URI.

URL -- Uniform Resource Locator

Contains information about how to fetch a resource from its location. For example:

  • http://example.com/mypage.html
  • ftp://example.com/download.zip
  • mailto:[email protected]
  • file:///home/user/file.txt
  • tel:1-888-555-5555
  • http://example.com/resource?foo=bar#fragment
  • /other/link.html (A relative URL, only useful in the context of another URL)

URLs always start with a protocol (http) and usually contain information such as the network host name (example.com) and often a document path (/foo/mypage.html). URLs may have query parameters and fragment identifiers.

URN -- Uniform Resource Name

Identifies a resource by a unique and persistent name, but doesn't necessarily tell you how to locate it on the internet. It usually starts with the prefix urn: For example:

  • urn:isbn:0451450523 to identify a book by its ISBN number.
  • urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66 a globally unique identifier
  • urn:publishing:book - An XML namespace that identifies the document as a type of book.

URNs can identify ideas and concepts. They are not restricted to identifying documents. When a URN does represent a document, it can be translated into a URL by a "resolver". The document can then be downloaded from the URL.

URC -- Uniform Resource Citation

Points to meta data about a document rather than to the document itself. An example of a URC is one that points to the HTML source code of a page like: view-source:http://example.com/

Data URI

Rather than locating it on the internet, or naming it, data can be placed directly into a URI. An example would be data:,Hello%20World.


Frequently Asked Questions

I've heard that I shouldn't say URL anymore, why?

The W3 spec for HTML says that the href of an anchor tag can contain a URI, not just a URL. You should be able to put in a URN such as <a href="urn:isbn:0451450523">. Your browser would then resolve that URN to a URL and download the book for you.

Do any browsers actually know how to fetch documents by URN?

Not that I know of, but modern web browser do implement the data URI scheme.

Does the difference between URL and URI have anything to do with whether it is relative or absolute?

No. Both relative and absolute URLs are URLs (and URIs.)

Does the difference between URL and URI have anything to do with whether it has query parameters?

No. Both URLs with and without query parameters are URLs (and URIs.)

Does the difference between URL and URI have anything to do with whether it has a fragment identifier?

No. Both URLs with and without fragment identifiers are URLs (and URIs.)

Does the difference between URL and URI have anything to do with what characters are permitted?

No. URLs are defined to be a strict subset of URIs. If a parser allows a character in a URL but not in a URI, there is a bug in the parser. The specs go into great detail about which characters are allowed in which parts of URLs and URIs. Some characters may be allowed only in some parts of the URL, but characters alone are not a difference between URLs and URIs.

But doesn't the W3C now say that URLs and URIs are the same thing?

Yes. The W3C realized that there is a ton of confusion about this. They issued a URI clarification document that says that it is now OK to use the terms URL and URI interchangeably (to mean URI). It is no longer useful to strictly segment URIs into different types such as URL, URN, and URC.

Can a URI be both a URL and a URN?

The definition of URN is now looser than what I stated above. The latest RFC on URIs says that any URI can now be a URN (regardless of whether it starts with urn:) as long as it has "the properties of a name." That is: It is globally unique and persistent even when the resource ceases to exist or becomes unavailable. An example: The URIs used in HTML doctypes such as http://www.w3.org/TR/html4/strict.dtd. That URI would continue to name the HTML4 transitional doctype even if the page on the w3.org website were deleted.


URI/URL Venn Diagram

@bvdb 2015-05-18 07:36:09

is "C:\myfile" an URI,URL or URN ? or none of them.

@Stephen Ostermiller 2015-06-08 16:19:43

A file path is not a URL or URI unless you put the file:// prefix on it. Although browsers do generally handle non-URL formatted file paths. Mozilla publishes their test cases for file URLs.

@hkBattousai 2015-07-05 01:30:56

Why are they "uniform"?

@Stephen Ostermiller 2015-07-05 02:11:57

See section 1.1 of the RFC -- "Uniformity provides several benefits. It allows different types of resource identifiers to be used in the same context, even when the mechanisms used to access those resources may differ. It allows uniform semantic interpretation of common syntactic conventions across different types of resource identifiers..."

@user31782 2016-10-20 07:06:35

You have mentioned mailto:[email protected] as a URL but another answer below says it is a URN? Which is right? Is it both URN and URL?

@Stephen Ostermiller 2016-10-20 12:15:36

It is best just to say that it is a URI because it is no longer advised to segment URIs in to various types. Because all URIs are now URLs, you can certainly call any URI a URL, including mailto. However, I tihnk that even under the classical definition of a URL, mailto would be a URL. It specifies the location of a resource on a network. It provides the host name and mailbox name to which you can actually send data over the network. In fact, the RFC for mailto refers to it as a URL. It also names a person, so you could argue it could be a URN too.

@vee 2017-05-22 07:41:58

This answer is a lot more easy to understand. I can see the clearly pictures of real example of the URLs & URN. And for anyone to read more about this... danielmiessler.com/study/url-uri

@Jon Skeet 2008-10-06 21:29:48

From RFC 3986:

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"). The term "Uniform Resource Name" (URN) has been used historically to refer to both URIs under the "urn" scheme [RFC2141], which are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable, and to any other URI with the properties of a name.

So all URLs are URIs (actually not quite - see below), and all URNs are URIs - but URNs and URLs are different, so you can't say that all URIs are URLs.

EDIT: I had previously thought that all URLs are valid URIs, but as per comments:

Not "all URLs are URIs". It depends on the interpretation of the RFC. For example in Java the URI parser does not like [ or ] and that's because the spec says "should not" and not "shall not".

So that muddies the waters further, unfortunately.

If you haven't already read Roger Pate's answer, I'd advise doing so as well.

@Mark Cidade 2008-10-06 21:38:57

Only URIs with the urn: scheme are URNs. A URI could be a classic URL, a URN, or just a URI that doesn't start with "urn:" and doesn't refer to a location of a resource.

@Michael Stum 2008-10-06 21:49:54

One example are InfoPath URNs, which are important i.e. in Sharepoint Workflows: urn:schemas-microsoft-com:office:infopath:blogsample:-myXSD-‌​2004-05-19T20-48-18

@Julian Reschke 2010-03-11 12:20:46

Note that RFC 2396 has been obsoleted by RFC 3986 a long time ago (but that doesn't change the facts...)

@Adam Gent 2013-05-16 00:47:40

Not "all URLs are URIs". It depends on the interpretation of the RFC. For example in Java the URI parser does not like [ or ] and that's because the spec says "should not" and not "shall not".

@Hubert 2013-06-16 23:32:09

@AdamGent: RFC 3986 1.1.3: "A URI can be further classified as a locator, a name, or both." So, if URL is a special kind of URI, that means that every URL is a URI. Doesn't it?

@Adam Gent 2013-06-17 00:06:34

It depends on your semantics of "special". URLs are not a syntactical subset of URI just like C is not truly a syntacticaly a subset of C++ (IIRC ... That might have changed).

@Andrew Janke 2014-03-11 05:00:37

@AdamGent: That sounds like a Java implementation quirk, and not normative. The java.net.URI doc itself says "every URL is a URI, abstractly speaking, but not every URI is a URL". And java.net.URL does weird stuff like checking equality of URLs by resolving host names to IP addresses (which seems at odds with RFC 3986 sec 6 in the first place, and breaks w virtual hosts). I think this just means the Java Standard Library has some inconsistent class behavior.

@Andrew Janke 2014-03-11 07:27:30

I think I figured out the Java [ and ] bracket thing. RFC 3986 sec 3.2.2 says "[IPv6 host addresses] is the only place where square bracket characters are allowed in the URI syntax." If you use them in the right place, java.net.URI accepts them. new java.net.URI("foo://[1080:0:0:0:8:800:200C:417A]/a/b") succeeds for me in Java 1.7. "foo://example.com/a[b]" errors. This sounds in line with the RFC. The form new URI("http", "example.com", "/a/b[c]!$&'()*+", null, null) will %-encode the []. That java.net.URL accepts them elsewhere sounds like it's doing less validation.

@Jon Skeet 2014-03-11 08:53:47

@AndrewJanke: Thanks - not entirely sure where that leaves my answer, admittedly :)

@Adam Gent 2014-03-11 12:43:53

@AndrewJanke Actually its the opposite. The URI parser in Java is stricter (as in it follows the should not) and yes other languages like Python have this problem : urlparse.urlparse('http://blah.com/a[b') and urlparse.parse_qsl('a=[',True,True) should fail but does not (notice how I even passed the strict option on that last one). I blogged about this here which has some more relevant links: adamgent.com/post/25161273526/urls-are-not-a-subset-of-uris . You should also know all of the servlet containers (I have used) will happily pass you URLs with [ and ] in the path.

@Andrew Janke 2014-03-11 19:58:30

@AdamGent Maybe I need to do some more reading on this. Where is the "should not" you're referring to? In RFCs back to RFC 1630, I only see them saying that [ and ] "must" be escaped or "may not" appear.

@Adam Gent 2014-03-11 20:08:09

@AndrewJanke I included the link in my blog post (you might have missed it) tools.ietf.org/html/rfc2396#section-2.4.3 (the continued page 10). Yes that is RFC 2396 but most things probably follow that older spec instead of RFC 3986 which I haven't looked at extensively.

@Adam Gent 2014-03-11 20:12:45

@AndrewJanke The characters like [, ] are called unwise hence the should not. I can't find where it says should not for unwise (maybe an older spec) but its definitely inferred.

@Andrew Janke 2014-03-11 20:12:58

@AdamGent Yes, I read it from your blog post. The word "should" doesn't appear in section 2.4.3. The normative language is in the last sentence, and it's a "must": "Data corresponding to excluded characters must be escaped in order to be properly represented within a URI." Maybe it's a different section?

@Adam Gent 2014-03-11 20:15:32

@AndrewJanke I'm not really sure. My goal just like my blog post is not really to be pedantic but informative for others to avoid the pitfalls I have had. In the new spec for URI, URL might be a subset of URI but in the wild that is certainly not the case.

@Andrew Janke 2014-03-11 21:06:38

@JonSkeet Maybe just need to differentiate between standards vs implementations? E.g. "Formally, according to RFCs, all URLs are URIs. (RFC excerpt.) But existing implementations may not match the spec exactly, possibly for interoperability, and may use URLs that are not valid per the RFCs. And because it's a complicated area, some people and documents might use 'URL' to mean something different from the RFC-specified thing." Sort of like how most email validation routines don't match the RFC definitions.

@Andrew Janke 2014-03-11 21:07:11

@Adam Gent 2014-07-10 12:58:44

@AndrewJanke @Jon Skeet Here is a SO answer to the "should" on [,]: stackoverflow.com/a/1547922/318174

@strizzwald 2019-04-02 08:58:09

Would you then say all relative URLs are actually just URIs?

@Jon Skeet 2019-04-02 09:17:54

@strizzwald: I don't think I'd venture an opinion...

@Premraj 2015-12-23 11:45:30

Identifier = Name + Location

Every URL(Uniform Resource Locator) is a URI(Uniform Resource Identifier), abstractly speaking, but every URI is not a URL. There is another subcategory of URI is URN (Uniform Resource Name), which is a named resource but do not specify how to locate them, like mailto, news, ISBN is URIs. Source

enter image description here

URN:

  • URN Format : urn:[namespace identifier]:[namespace specific string]
  • urn: and : stand for themselves.
  • Examples:
    • urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66
    • urn:ISSN:0167-6423
    • urn:isbn:096139210x
    • Amazon Resource Names (ARNs) is a uniquely identify AWS resources.
      • ARN Format : arn:partition:service:region:account-id:resource

URL:

  • URL Format : [scheme]://[Domain][Port]/[path]?[queryString]#[fragmentId]
  • :,//,? and # stand for themselves.
  • schemes are https,ftp,gopher,mailto,news,telnet,file,man,info,whatis,ldap...
  • Examples:

Analogy:
To reach a person: Driving(protocol others SMS, email, phone), Address(hostname other phone-number, emailid) and person name(object name with a relative path).

@Rex Schrader 2019-03-01 17:03:43

Minor quibble: There should be a colon between [domain] and [port]. IE: example.com:1234

@user7987783 2017-07-21 17:50:21

First of all get your mind out of confusion and take it simple and you will understand.

URI => Uniform Resource Identifier Identifies a complete address of resource i-e location, name or both.

URL => Uniform Resource Locator Identifies location of the resource.

URN => Uniform Resource Name Identifies the name of the resource

Example

We have address https://www.google.com/folder/page.html where,

URI(Uniform Resource Identifier) => https://www.google.com/folder/page.html

URL(Uniform Resource Locator) => https://www.google.com/

URN(Uniform Resource Name) => /folder/page.html

URI => (URL + URN) or URL only or URN only

@Bruno Bronosky 2015-03-10 18:24:59

In order to answer this I'll lean on an answer I modified to another question. A good example of a URI is how you identify an Amazon S3 resource. Let's take:

s3://www-example-com/index.html [fig. 1]

which I created as a cached copy of

http://www.example.com/index.html [fig. 2]

in Amazon's S3-US-West-2 datacenter.

Even if StackOverflow would allow me to hyperlink to the s3:// protocol scheme, it wouldn't do you any good in locating the resource. Because it Identifies a Resource, fig. 1 is a valid URI. It is also a valid URN, because Amazon requires that the bucket (their term for the authority portion of the URI) be unique across datacenters. It is helpful in locating it, but it does not indicate the datacenter. Therefore it does not work as a URL.

So, how do URI, URL, and URN differ in this case?

NOTE: RFC 3986 defines URIs as scheme://authority/path?query#fragment

@Rick O'Shea 2016-03-07 18:56:49

Don't forget URNs. URIs and URLs are both URNs. URLs have a location:

URI: foo
URL: http://some.domain.com/foo
URL: http://some.domain.com:8080/foo
URL: ftp://some.domain.com/foo

They're all URNs.

@Craig Silver 2016-11-12 01:22:09

Those are all URN's? I'm still unsure of the semantics of each but, syntactically, I thought that a URN has no slashes (//). See en.wikipedia.org/wiki/Uniform_Resource_Identifier Or is the lack of // just the typical case and not a syntactic requirement of a URN?

@Tim Gautier 2018-01-10 17:35:24

This is wrong. URN is not the super set, URI is.

@Rakeeb Rajbhandari 2013-08-11 04:41:38

I found:


A uniform resource identifier(URI) represents something of a big picture. You can split URIs/ URIs can be classified as locators (uniform resource locators- URL), or as names (uniform resource name-URN), or either both. So basically, a URN functions like a person's name and the URL depicts that person's address. So long story short, a URN defines an item's identity, while the URL provides defines the method for finding it, finally encapsulating these two concepts is the URI

@Prashanth Sams 2014-08-28 09:29:00

As per RFC 3986, URIs are comprised of the following pieces:

scheme://authority/path?query

The URI describes the protocol for accessing a resource (path) or application (query) on a server (authority).

Enter image description here

All the URLs are URIs, and all the URNs are URIs, but all the URIs are not URLs.

Please refer for more details:

Wikipedia

@ccjmne 2014-09-06 11:06:06

This doesn't teach me anything that's not covered by the other answers that are at least 6 years old, and which are much more complete and actually try to explain how to distinguish URIs from URLs.

@Stephen Ostermiller 2015-04-17 10:03:57

It is important to note that the image is a Venn diagram even though it doesn't look like a typical one. I've seen people try to interpret it as "parts of the URL". This diagram does not say that URIs start with a URL and end with a URN.

@Adiii 2016-06-02 11:16:26

URI and URL

URI, URL, URN

As the image above indicates, there are three distinct components at play here. It’s usually best to go to the source when discussing matters like these, so here’s an exerpt from Tim Berners-Lee, et. al. in RFC 3986: Uniform Resource Identifier (URI): Generic Syntax:

A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.

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”).

@Greg 2009-12-31 06:51:06

In summary: a URI identifies, a URL identifies and locates.

Consider a specific edition of Shakespeare's play Romeo and Juliet, of which you have a digital copy on your home network.

You could identify the text as urn:isbn:0-486-27557-4.
That would be a URI, but more specifically a URN* because it names the text.

You could also identify the text as file://hostname/sharename/RomeoAndJuliet.pdf.
That would also be a URI, but more specifically a URL because it locates the text.

*Uniform Resource Name

(Note that my example is adapted from Wikipedia)

@Michael Brewer-Davis 2009-12-31 18:15:35

It's helpful to note the actual URN (to see how it compares to a URL): urn:isbn:0-486-27557-4

@Greg 2009-12-31 18:47:09

@Michael - It is my understanding that ISBN 0486275574 also names the text and thus qualify as a URN. I choose a format that I believed would be more familiar to readers.

@johnsimer 2016-06-06 14:01:14

So would it make sense to say that the hash (e.g. SHA1) of a file could be a URN for that file?

@Dennis98 2018-02-06 19:34:30

@johnsimer Don't think so, as you could have a copy of one file on the same computer, which would result into the same hash and therefore it's not unique.

@dierre 2010-05-15 14:25:47

I was wondering about the same thing and I've found this: http://docs.kohanaphp.com/helpers/url.

You can see a clear example using the url::current() method. If you have this URL: http://example.com/kohana/index.php/welcome/home.html?query=string then using url:current() gives you the URI which, according to the documentation, is: welcome/home

@Stephen Ostermiller 2015-04-17 10:07:50

This answer is wrong. A URI is not a portion of the URL. Rather URLs are a type of URI. Furthermore, the link in this answer is broken (and I can not find a suitable replacement.)

@Phil Sturgeon 2009-12-31 08:58:59

These are some very well-written but long-winded answers. Here is the difference as far as CodeIgniter is concerned:

URL - http://example.com/some/page.html

URI - /some/page.html

Put simply, URL is the full way to indentify any resource anywhere and can have different protocols like FTP, HTTP, SCP, etc.

URI is a resource on the current domain, so it needs less information to be found.

In every instance that CodeIgniter uses the word URL or URI this is the difference they are talking about, though in the grand-scheme of the web, it is not 100% correct.

@Phil Sturgeon 2009-12-31 12:18:19

This answer may be over-simplified but look at the context of his question. It will be more helpful to him that waffling on about XML namespaces!

@Jörg W Mittag 2009-12-31 12:40:57

This answer is not only wrong but actively misleading. Both examples are URLs. And since every URL is also a URI, this means that both examples are URIs. For the purpose of demonstrating the difference between URIs and URLs, this is totally useless.

@Phil Sturgeon 2010-01-11 11:13:00

This is the difference as far as CodeIgniter is concerned. In every instance they use the word URL or URI this is the difference they are talking about. Therefore in the grand-scheme of the web, it is not 100% correct but in the scope of the OP's question (the difference in CodeIgniter), this answer is perfectly correct.

@Matt 2010-01-11 11:20:18

@Phil Sturgeon - agreed, for the purpose of this question, this is how CI distinguishes between URL and URI.

@Udders 2010-01-11 11:53:34

@Phil Sturgeon - for the purpose of the question your answer is perfectly fine

@Dennis 2014-03-10 15:20:55

@JörgWMittag what examples would you give if you were to improve the answer?

@Andrew Janke 2014-03-11 05:33:19

This is wrong. @JörgWMittag is mostly on point. URLs are URIs, and they're "fully qualified"; so the "URL" in this answer is both. But /some/page.html is not a URI. It is a "relative-ref", which is a kind of "URI-reference". Combined with a base URI context, it can be resolved to a URI, but is not itself a URI. See Section 4.1 of RFC 3986. CodeIgniter's probably using the terms wrong and that should be called out; the Q (as currently edited) isn't framed as CodeIgniter-specific.

@Phil Sturgeon 2014-03-11 13:17:51

When I answered the question it was tagged under #codeigniter. so it was answered as such.

@Matmarbon 2014-07-06 15:51:58

It seems, not only CI but also at least PHP's $_SERVER['REQUEST_URI'] distinguishes like this.

@Kenney 2014-09-23 16:42:34

If /some/page.html is not an URI then it is definitely not an URL - it's not complete enough for me to locate the resource.

@ArtOfWarfare 2014-10-06 17:33:08

For future people who read these comments and are as confused as I was: This answer wasn't posted for this question. This question never had anything to do with CodeIgniter. There was a duplicate question which specifically mentioned CodeIgniter which was closed and had all of its answers migrated over to this question. This answer was one of those which were moved from the old closed question to this protected question. Even so, I this answer is misleading. I have downvoted it - others should do the same since, in its new home, it is wrong. The author should delete it or the merge be undone.

@pcs 2015-08-21 06:12:14

Hello sir.. after read your answer, I finalized ,the answer of this * In the network HTTP resources are located by?* .. URL ... but in that sanfoundry.com/computer-networks-questions-answers-http-ftp they answered URI .so.. may i know, what is the answer? thanks

@loyola 2015-02-10 10:09:13

Easy to explain:

Lets assume the following

URI is your Name

URL is your address with your name in-order to communicate with you.

  • my name is Loyola

    Loyola is URI

  • my address is TN, Chennai 600001.

TN, Chennai 600 001, Loyola is URL

Hope you understand,

Now lets see a precise example

http://www.google.com/fistpage.html

in the above you can communicate with a page called firstpage.html (URI) using following http://www.google.com/fistpage.html(URL).

Hence URI is subset of URL but not vice-versa.

@Vegan Sv 2015-12-28 00:54:13

This answer is misleading. Quote from Wikipedia "A Uniform Resource Name (URN) functions like a person's name, while a Uniform Resource Locator (URL) resembles that person's street address. In other words: the URN defines an item's identity, while the URL provides a method for finding it." Also both URNs and URLs are URIs.

@Swapnil 2009-12-31 07:51:39

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 opinion. A URI has two specializations known as URL and URN.

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://stackoverflow.com, etc. But a URL doesn’t have to be an HTTP URL, it can be ftp://example.com, etc.

@user2481398 2014-12-03 06:19:05

A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource.

The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address. Another, not so common type of URI is the Universal Resource Name (URN).

@Gustavo Mori 2014-10-16 17:46:51

A small addition to the answers already posted, here's a Venn's diagram to sum up the theory (from Prateek Joshi's beautiful explanation):

enter image description here

And an example (also from Prateek's website):

enter image description here

@ruvim 2014-12-04 14:57:40

I believe the second illustration is incorrect. By the specification url.spec.whatwg.org/#url-writing A URL must be written as either a relative URL or an absolute URL, optionally followed by "#" and a fragment. So, #posts fragment identifier could be part of the URL

@Engineer Dollery 2015-02-03 11:10:53

This is just plain wrong

@patapouf_ai 2015-06-28 00:22:00

The two illustrations contradict each other.

@Roger Pate 2009-12-31 06:32:58

URIs identify and URLs locate; however, locators are also identifiers, so every URL is also a URI, but there are URIs which are not URLs.

Examples

  • Roger Pate

This is my name, which is an identifier. It is like a URI, but cannot be a URL, as it tells you nothing about my location or how to contact me. In this case it also happens to identify at least 5 other people in the USA alone.

  • 4914 West Bay Street, Nassau, Bahamas

This is a locator, which is an identifier for that physical location. It is like both a URL and URI (since all URLs are URIs), and also identifies me indirectly as "resident of..". In this case it uniquely identifies me, but that would change if I get a roommate.

I say "like" because these examples do not follow the required syntax.

Popular confusion

From Wikipedia:

In computing, a Uniform Resource Locator (URL) is a subset of the Uniform Resource Identifier (URI) that specifies where an identified resource is available and the mechanism for retrieving it. In popular usage and in many technical documents and verbal discussions it is often incorrectly used as a synonym for URI, ... [emphasis mine]

Because of this common confusion, many products and documentation incorrectly use one term instead of the other, assign their own distinction, or use them synonymously.

URNs

My name, Roger Pate, could be like a URN (Uniform Resource Name), except those are much more regulated and intended to be unique across both space and time.

Because I currently share this name with other people, it's not globally unique and would not be appropriate as a URN. However, even if no other family used this name, I'm named after my paternal grandfather, so it still wouldn't be unique across time. And even if that wasn't the case, the possibility of naming my descendants after me make this unsuitable as a URN.

URNs are different from URLs in this rigid uniqueness constraint, even though they both share the syntax of URIs.

@eugene 2013-07-11 19:30:36

URNs are different from URLs in this rigid uniqueness constraint Does this mean that URLs don't uniquely identify a location?

@netjeff 2013-07-26 23:23:24

Roger's answer provides good pragmatic advice. For the official answer I go to the W3C who published "URIs, URLs, and URNs: Clarifications and Recommendations" in 2001. In a nutshell, W3C says the contemporary view is that everything is a URI. URL is an informal concept, not a formal concept. And the confusion dates back to a "classical view" which tried to rigidly distinguish between categories of URI (of which URL was one category).

@n611x007 2013-11-21 18:30:43

If URNs are meant to be unique in both space and time, what will be done with sg. like URN-squatting, akin to domainsquatting?

@Arne 2014-04-28 07:51:38

..a Uniform Resource Locator (URL).. specifies where an identified resource is available and the mechanism for retrieving it. So in other words, there is no such thing as a "relative" URL?

@Ciro Santilli 新疆改造中心996ICU六四事件 2014-08-20 20:56:02

@eugene I think the point is that they specify a location, but not the content. E.g., next year the domain name could be bought by another company that puts up a completely different page. An ISBN however (URN) will never change.

@edelwater 2014-09-20 03:06:25

Is "earth128:Edward-de-Leau/6000000000569063853" (the unique me over multiple multiverse) a URN, a URL or a URI?

@The Gilbert Arenas Dagger 2015-02-19 22:02:09

I can't help but think back to geometry... The URI is the quadrilateral and the URL is the rectangle. A rectangle is always a quadrilateral, but a quadrilateral is only sometimes a rectangle. Too nerdy?

@user20358 2015-04-27 10:57:23

@edelwater: I suppose thats a uri as it only identifies you but says nothing of how to get to you, unless you mean earth128 is some medium of inter-planetary travel :)

@Svish 2015-10-29 12:08:48

@Arne I'd say relative URLs definitely is a thing, but they are of course dependent upon the URL they are relative to, which is where you'll find the mechanism for retrieving it and/or whatever else is missing from the relative one. I suppose you could also call relative URLs a shorthand form of the full URL. So even though it looks relative, it actually is absolute, you just have to add in the context of it.

@Fernando Gabrieli 2016-12-16 17:00:44

so to add an example i could say that a URI is like "fernando" (my name) and a URL is my email "[email protected]", is this correct? thanks

@Jin Kwon 2017-01-23 08:00:55

CIA would like information in this answer.

@sarathkm 2017-02-03 04:58:54

I guess domain name can be quoted as URN, as its unique in its nature. There can not be no two top level .com with same name.

@Jeb50 2017-11-05 00:10:04

Art of speech of communication is to be able to use commonly-use plain English to explain rocket science! Kudo

@Dushantha 2018-01-13 17:15:27

@icc97 2018-04-09 07:44:12

@netjeff This quote from the URI clarification contempory section: "An http URI is a URL", probably covers about 99% of what people use

@Peter Boughton 2008-10-06 21:30:02

Wikipedia will give all the information you need here. Quoting from http://en.wikipedia.org/wiki/URI:

A 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".

@Sujit 2012-09-08 08:17:25

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://example.com etc. But a URL doesn't have to be an HTTP URL, it can be ftp://example.com etc., too.

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 opinion. A URI has two specializations known as URL and URN.

Difference between URL and URI

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.

@D.C. 2009-12-31 07:38:04

Another example I like to use when thinking about URIs is the xmlns attribute of an XML document:

<rootElement xmlns:myPrefix="com.mycompany.mynode">
    <myPrefix:aNode>some text</myPrefix:aNode>
</rootElement>

In this case com.mycompany.mynode would be a URI that uniquely identifies the "myPrefix" namespace for all of the elements that use it within my XML document. This is NOT a URL because it is only used to identify, not to locate something per se.

@manuel aldana 2009-12-31 12:59:17

Due to difficulties to clearly distinguish between URI and URL, as far as I remember W3C does not make a difference any longer between URI and URL (http://www.w3.org/Addressing/).

@Tim Gautier 2018-01-10 17:28:45

Maybe I missed that part, but I don't see any reference in the provided link to them removing the distinction between URL and URI, only acknowledging the confusion and wanting specs that are incorrectly referencing URL to be updated to reference URI instead.

@jjolla 2012-08-29 01:31:59

Here is my simplification:

URN: unique resource name, i.e. "what" (eg urn:issn:1234-5678 ). This is meant to be unique .. as in no two different docs can have the same urn. A bit like "uuid"

URL: "where" to find it ( eg https://google.com/pub?issnid=1234-5678 .. or ftp://somesite.com/doc8.pdf )

URI: can be either a URN or a URL. This fuzzy definition is thanks to RFC 3986 produced by W3C and IETF.

The definition of URI has changed over the years, so it makes sense for most people to be confused. However, you can now take solace in the fact that you can refer to http://somesite.com/something as either a URL or URI ... an you will be right either way (at least fot the time being anyway...)

@paul r 2012-10-06 20:05:52

After reading through the posts, I find some very relevant comments. In short, the confusion between the URL and URI definitions is based in part on which definition depends on which and also informal use of the word URI in software development.

By definition URL is a subset of URI [RFC2396]. URI contain URN and URL. Both URI and URL each have their own specific syntax that confers upon them the status of being either URI or URL. URN are for uniquely identifying a resource while URL are for locating a resource. Note that a resource can have more than one URL but only a single URN.[RFC2611]

As web developers and programmers we will almost always be concerned with URL and therefore URI. Now a URL is specifically defined to have all the parts scheme:scheme-specific-part, like for example https://stackoverflow.com/questions. This is a URL and it is also a URI. Now consider a relative link embedded in the page such as ../index.html. This is no longer a URL by definition. It is still what is referred to as a "URI-reference" [RFC2396].

I believe that when the word URI is used to refer to relative paths, "URI-reference" is actually what is being thought of. So informally, software systems use URI to refer to relative pathing and URL for the absolute address. So in this sense, a relative path is no longer a URL but still URI.

@dpant 2012-03-10 17:30:22

URIs came about from the need to identify resources on the Web, and other Internet resources such as electronic mailboxes in a uniform and coherent way. So, one can introduce a new type of widget: URIs to identify widget resources or use tel: URIs to have web links cause telephone calls to be made when invoked.

Some URIs provide information to locate a resource (such as a DNS host name and a path on that machine), while some are used as pure resource names. The URL is reserved for identifiers that are resource locators, including 'http' URLs such as http://stackoverflow.com, which identifies the web page at the given path on the host. Another example is 'mailto' URLs, such as mailto:[email protected], which identifies the mailbox at the given address.

URNs are URIs that are used as pure resource names rather than locators. For example, the URI: mid:[email protected] is a URN that identifies the email message containing it in its 'Message-Id' field. The URI serves to distinguish that message from any other email message. But it does not itself provide the message's address in any store.

@Kevin Lowe 2011-12-01 13:07:15

This is one of the most confusing and possibly irrelevant topics I've encountered as a web professional.

As I understand it, a URI is a description of something, following an accepted format, that can define both or either the unique name (identification) of something and its location.

There are two basic subsets - URLs, which define location (especially to a browser trying to look up a webpage) and URNs, which define the unique name of something.

I tend to think of URNs as being similar to GUIDs. They are simply a standardized methodology for providing unique names for things. As in the namespace declarative that uses a company's name - it's not like there is a resource sitting on a server somewhere to correspond to that line of text - it simply uniquely identifies something.

I also tend to completely avoid the term URI and discuss things only in terms of URL or URN as appropriate, because it causes so much confusion. The question we should really try answering for people isn't so much the semantics, but how to identify when encountering the terms whether or not there is any practical difference in them that will change the approach to a programming situation. For example, if someone corrects me in conversation and says, "oh, that's not a URL it's a URI" I know they're full of it. If someone says "we're using a URN to define the resource" I'm more likely to understand we are only naming it uniquely, not locating it on a server.

If I'm way off base - please let me know!

@Alexander Pritchard 2015-04-06 14:33:12

No, I think you're right. The semantics of URI vs URL vs URL vs URI-ref etc. are useless to most developers, only because it drives pointless (non-productive, insignificant to decision making) debate. If the Google API used redirect_url instead of redirect_uri, would anyone really care?

@Freeman 2011-04-27 09:09:37

The answer is ambiguous. In Java it is frequently used in this way:

An Uniform Resource Locator (URL) is the term used to identify an Internet resource including the scheme( http, https, ftp, news, etc.). For instance What is the difference between a URI, a URL and a URN?

An Uniform Resource Identifier (URI) is used to identify a single document in the Web Server: For instance /questions/176264/whats-the-difference-between-a-uri-and-a-url

In Java servlets, the URI frequently refers to the document without the web application context.

@Holger Just 2012-09-08 08:43:22

This is the difference between an absolute and a relative URL. It doesn't explain the relation of URI vs. URL and URN.

@Zenexer 2013-11-11 03:49:38

Actually, these are accurate examples. On the Web, this is very often the difference.

@Gumbo 2009-12-31 09:57:27

Although the terms URI and URL are strictly defined, many use the terms for other things than they are defined for.

Let’s take Apache for example. If http://example.com/foo is requested from an Apache server, you’ll have the following environment variables set:

  • REDIRECT_URL: /foo
  • REQUEST_URI: /foo

With mod_rewrite enabled, you will also have these variables:

  • REDIRECT_SCRIPT_URL: /foo
  • REDIRECT_SCRIPT_URI: http://example.com/foo
  • SCRIPT_URL: /foo
  • SCRIPT_URI: http://example.com/foo

This might be the reason for some of the confusion.

@avpx 2009-12-31 06:33:44

See this document. Specifically,

a URL is a type of URI that identifies a resource via a representation of its primary access mechanism (e.g., its network "location"), rather than by some other attributes it may have.

It's not an extremely clear term, really.

@Mark Cidade 2008-10-06 21:28:43

They're the same thing. A URI is a generalization of a URL. Originally, URIs were planned to be divided into URLs (addresses) and URNs (names) but then there was little difference between a URL and URI and http URIs were used as namespaces even though they didn't actually locate any resources.

@Chris Charabaruk 2008-10-06 21:30:00

I thought it was the other way around. A URL refers to a concrete object, and a URI can refer to that or a concept or anything else.

@Mark Cidade 2008-10-06 21:33:40

A URL locates a resource and is a kind of URI, which identifies a resource.

@Stephen Ostermiller 2015-04-17 10:11:02

It is only true that they are the same thing because the definition of URL has changed over time. URLs used to be a specific type of URI, but because of the confusion that caused, the W3C redefined URL to mean URI.

@Mark Cidade 2015-04-17 18:59:29

That's what I said.

@André 2008-10-06 21:30:40

URI is kind of the super class of URL's and URN's. Wikipedia has a fine article about them with links to the right set of RFCs.

Related Questions

Sponsored Content

19 Answered Questions

[SOLVED] How do I modify the URL without reloading the page?

14 Answered Questions

[SOLVED] Encode URL in JavaScript?

15 Answered Questions

[SOLVED] How to change the URI (URL) for a remote Git repository?

  • 2010-03-12 12:48:47
  • e-satis
  • 1345628 View
  • 3375 Score
  • 15 Answer
  • Tags:   git url git-remote

32 Answered Questions

[SOLVED] What exactly is RESTful programming?

  • 2009-03-22 14:45:39
  • hasen
  • 1624162 View
  • 3892 Score
  • 32 Answer
  • Tags:   http rest definition

20 Answered Questions

[SOLVED] Get the current URL with JavaScript?

  • 2009-06-23 19:26:45
  • dougoftheabaci
  • 2668959 View
  • 2834 Score
  • 20 Answer
  • Tags:   javascript url

30 Answered Questions

[SOLVED] Get current URL with jQuery?

16 Answered Questions

[SOLVED] What is the maximum length of a URL in different browsers?

  • 2009-01-06 16:14:30
  • Sander Versluys
  • 1161746 View
  • 4597 Score
  • 16 Answer
  • Tags:   http url browser

7 Answered Questions

[SOLVED] What is the difference between POST and GET?

4 Answered Questions

[SOLVED] What is the difference between URI, URL and URN?

  • 2011-02-06 12:40:30
  • thom
  • 239610 View
  • 245 Score
  • 4 Answer
  • Tags:   http url uri urn

2 Answered Questions

[SOLVED] What's difference between URL,URN and URI?

  • 2013-09-03 12:20:48
  • Yasmeen Ansari
  • 1309 View
  • -3 Score
  • 2 Answer
  • Tags:   http url uri urn

Sponsored Content