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?
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?
Wikipedia will give all the information you need here. Quoting from http://en.wikipedia.org/wiki/URI:
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:fred@mail.org, 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:0E4FC272-5C02-11D9-B115-000A95B55BC8@stackoverflow.com 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.
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/).
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):
And an example (also from Prateek's website):
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 usingurl:current()
gives you the URI which, according to the documentation, is: welcome/homeIn 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://
protocolscheme, 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 theauthority
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