What's the difference between an URI, URL and URN? I have read a lot of sites (even Wikipedia) but I don't understand it.
URI: http://www.foo.com/bar.html
URL: http://www.foo.com/bar.html
URN: bar.html
Is this correct?
What's the difference between an URI, URL and URN? I have read a lot of sites (even Wikipedia) but I don't understand it.
URI: http://www.foo.com/bar.html
URL: http://www.foo.com/bar.html
URN: bar.html
Is this correct?
A Uniform Resource Identifier (URI
) is a string of characters used to identify a name or a resource on the Internet.
A URI identifies a resource either by location, or a name, or both. A URI has two specializations known as URL and URN.
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. A URL defines how the resource can be obtained. It does not have to be a HTTP URL (http://
), a URL can also start with ftp://
or smb://
, specifying the protocol that's used to get the resource.
A Uniform Resource Name (URN
) is a Uniform Resource Identifier (URI) that uses the URN scheme, and does not imply availability of the identified resource. Both URNs (names) and URLs (locators) are URIs, and a particular URI may be both a name and a locator at the same time.
This diagram (source) visualizes the relationship between URI, URN, and URL:
The URNs are part of a larger Internet information architecture which is composed of URNs, URCs and URLs.
bar.html is not a URN. A URN is similar to a person's name, while a URL is like a street address. The URN defines something's identity, while the URL provides a location. Essentially URN vs. URL is "what" vs. "where". A URN has to be of this form <URN> ::= "urn:" <NID> ":" <NSS>
where <NID>
is the Namespace Identifier, and <NSS>
is the Namespace Specific String.
To put it differently:
I'd say the only thing left to make it 100% clear would be to have an example of an URI that is not an URL. We can use the examples in RFC3986:
URL: ftp://ftp.is.co.za/rfc/rfc1808.txt
URL: http://www.ietf.org/rfc/rfc2396.txt
URL: ldap://[2001:db8::7]/c=GB?objectClass?one
URL: mailto:[email protected]
URL: news:comp.infosystems.www.servers.unix
URL: telnet://192.0.2.16:80/
URN (not URL): urn:oasis:names:specification:docbook:dtd:xml:4.1.2
URN (not URL): tel:+1-816-555-1212 (disputed, see comments)
urn:isbn:0-486-27557-4
(a specific edition of Shakespeare's play Romeo and Juliet) is in fact a URN (and therefore it's a URI), but it's not a URL. –
Ked tel
example is not a perfect one as one might argue that it is in fact a URL (even tough it's not a URL in the common internet-influenced area). –
Ked +1
for the USA, 816
for Missouri, etc.). –
Ked <URN> ::= "urn:" <NID> ":" <NSS>
where <NID> is the Namespace Identifier, and <NSS> is the Namespace Specific String. –
Carditis tel
can't be an URN as URNs use the URI scheme urn
, or am I wrong? –
Aloeswood javascript:alert(123);
? Is this URI or URL? –
Daimyo <URN> ::= "urn:"...
and then give an example of an URN that's not of that form (tel:+1-816...
). Does an URN need to begin with urn:
? –
Quadriplegia https://google.com/example.html
can only pin the location down to "one of Google's (tens? hundreds? thousands?) data centers, somewhere in the world". Either way, the physical location has nothing to do with it - it's the ability to abstractly "locate" the thing through that scheme that makes something a URL: https://google.com/example.html
is precise enough to pin down example.html
at google.com
through HTTP. tel:...
is precise enough to pin down that phone in the global phone system. –
Annexation tel:
is URLs like tcp://
, udp://
and sctp://
. The part that follows is an IP address (and a port, but for many purposes that's just two more bytes of a total "address"). If you hit udp://8.8.8.8:9
, what exactly are you "locating"? Well, a computer(-like thing) which happens to currently have that address and port route to it from you. When you hit tel:
URwhatever, you are locating a phone(-like thing) which happens to currently have that number route to it from you. Seems rather same to me. –
Annexation Below I sum up Prateek Joshi's awesome explanation.
The theory:
That is:
And for an example:
Also, if you haven't already, I suggest reading Roger Pate's answer.
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
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.
Identifies a resource by name. It always 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 identifierurn: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.
URIs encompasses both URLs, URNs, and other ways to indicate a resource.
An example of a URI that is neither a URL nor a URN would be a data URI such as data:,Hello%20World
. It is not a URL or URN because the URI contains the data. It neither names it, nor tells you how to locate it over the network.
There are also uniform resource citations (URCs) that point to meta data about a document rather than to the document itself. An example of a URC would be an indicator for viewing the source code of a web page: view-source:http://example.com/
. A URC is another type of URI that is neither URL nor URN.
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.
Not that I know of, but modern web browser do implement the data URI scheme.
Good question. I've seen lots of places on the web that state this is true. I haven't been able to find any examples of something that is both a URL and a URN. I don't see how it is possible because a URN starts with urn:
which is not a valid network protocol.
No. Both relative and absolute URLs are URLs (and URIs.)
No. Both URLs with and without query parameters are URLs (and URIs.)
No. Both URLs with and without fragment identifiers are URLs (and URIs.)
tel:
URI a URL or a URN?For example tel:1-800-555-5555
. It doesn't start with urn:
and it has a protocol for reaching a resource over a network. It must be a URL.
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 URL and URI interchangeably. It is no longer useful to strictly segment URIs into different types such as URL, URN, and URC.
tel:
is a URI because it's an identifier. Read RFC 3966. It's not a URL, because it doesn't help you locate a resource on the web. There is no actual resource to link to, so that'd be impossible. For example, an anchor href URI for tel:
would instead launch whatever program is used to dial the number. –
Accustom urn
scheme while https://www.google.com/
is a URL that is also a URN (it both identifies and locates the Google Web Search resource). –
Thoroughpaced tel:
doesn't help you locate the resource. It is clearly telling you the you can reach it through the conventional telephony network using the PSTN system. Same thing as http:
says you can reach it with the DNS service using the plain text HTTP, https:
similarly but through TLS, and mailto:
using SMTP. What happens when you click on it or whether you have software that can handle a call or send an email is completely irrelevant for the semantics of a URL. Maybe the consumer of the tel:
is an automated calling system which can handle it easily. –
Carburet tel:
is just an ID; a URI. –
Accustom ftp://
and mailto://
are URLs they are NOT reachable via HTTP. Only http
URLs are. The ID in a tel:
URL is the telephone number, and saying it is a tel:
not only qualifies it but also specifies how to reach it (by calling it via PSTN). Can't see the difference between a tel:
URL and for example a sip:
URL. Even Microsoft refers to them as URLs: learn.microsoft.com/en-us/previous-versions/windows/desktop/… –
Carburet URI (Uniform Resource Identifier) according to Wikipedia:
a string of characters used to identify a resource.
URL (Uniform Resource Locator) is a URI that implies an interaction mechanism with resource. for example https://www.google.com specifies the use of HTTP as the interaction mechanism. Not all URIs need to convey interaction-specific information.
URN (Uniform Resource Name) is a specific form of URI that has urn as it's scheme. For more information about the general form of a URI refer to https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax
IRI (International Resource Identifier) is a revision to the definition of URI that allows us to use international characters in URIs.
© 2022 - 2024 — McMap. All rights reserved.