URL Vs URI Vs URN
Lets first look at full form:
UR - Uniform Resource URI - UR Identifier URL - UR Locator URN - UR Name
TLDR
- URI (uniform resource identifier) identifies a specific resource on the web (for e.g. text document, image file, etc)
- URL (uniform resource locator) is a subset of the URIs that include a network location. So, it not only identifies a resource but also provides a means of locating it by describing its primary access mechanism ( e.g. network location)
- URN (uniform resource name) is a subset of URIs that names a resource without implying its location or how it can be accessed. (eg.
urn:isbn:0451450523)
Generally,
| |
All URLs Are URIs, but Not Vice-versa
If a URL provides both the location and the name of a resource, it is considered a URI. While URIs serve to identify, URLs specify location; hence, identifying through a location means every URL is also a URI. However, some URIs are not URLs.
google.comis a URI as it is solely the name of a resource.https://google.comis a URL because it specifies both the name and how to access the resource.
Examples
The figure below should make things clearer:
| |
More Examples
| URIs | URNs | URLs |
|---|---|---|
| A name, name and location, or both | a name or number | a name/number with location |
| A name, a name and address, or both | Someone’s name or address | Someone’s name and address |
| An ISBN number | An ISBN number | mailto://[email protected] |
| [email protected] | [email protected] | mailto://[email protected] |
| [email protected] | ftp.google.com | ftp://ftp.google.com |
URL
Contains information about how to fetch a resource from its location. For example:
http://example.com/mypage.htmlftp://example.com/download.zipmailto:[email protected]file:///home/user/file.txthttp://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
Identifies a resource by name and begins with the prefix urn:. For instance:
urn:isbn:0451450523identifies a book by its ISBN number.urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66serves as a globally unique identifier.urn:publishing:bookdenotes an XML namespace that classifies the document as a book.
URNs can represent ideas and concepts, not just documents. When a URN does refer to a document, it can be converted into a URL through a “resolver,” allowing the document to be downloaded.
URI
URIs encompass URLs, URNs, and other methods of identifying a resource.
A URI that is neither a URL nor a URN could be a data URI like data:,Hello%20World. This type of URI contains the data directly and neither names it nor provides its network location.
Additionally, there are Uniform Resource Citations (URCs), which refer to metadata about a document instead of the document itself. For instance, view-source:http://example.com/ is a URC that allows viewing the source code of a webpage. URCs are another form of URI distinct from URLs and URNs.