Difference between URI,URL and URN
Contents
We are accessing the web pages,images, videos and so on in the internet.Those resources are stored in the some servers and it needs unique identifier or name to access it over the internet. Lets understand URI,URL and URN and how it is used to locate those resource and what is the difference between each of them in this article.
What is URI?
URI stands for Uniform Resource Identifier that is a string of characters to identifies an abstract or physical resource. Here the resource might be a document, a photo, web page or anything else. It has two specializations known as URL (Uniform Resource Locator) and URN (Uniform Resource Name). With the help of location(URL) or name(URN), or both (URL and URN), it identify the resource.
It introduces the new types of resource identifiers without interfering with the way that existing identifiers are used. It distinguishing one resource from all other resources, regardless of how that purpose is accomplished (e.g., by name, address, or context).
Example of URI
1 2 3 |
http://www.ietf.org/rfc/rfc2396.txt mailto:John.Doe@example.com telnet://192.0.2.16:80/ |
Syntax of URI
1 |
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] |
- Scheme name — The scheme identifies the protocol to be used to access the resource on the Internet. The scheme names followed by the three characters :// (a colon and two slashes). The most commonly used protocols are http://, https://, ftp://, and mailto://.
- hier-part – It contains the host name,port and path where resource is located. For example, www.revisitclass.com consists of host’s machine name www and the domain name revisitclass.com. Similarly web service HTTP runs by default over port 80, HTTPS runs by default over port 443.
- Query – The query string contains data to be passed to server-side scripts, running on the web server. The query string preceded by a question mark (?), is usually a string of name and value pairs separated by ampersand (&),
- Fragment – The fragment identifier, if present, specifies a location within the page. The fragment identifier introduced by a hash character (#) is the optional last part of a URL for a document.
What is URL?
Uniform Resource Locator(URL) is known as web address. It refers to the subset of URI and specify how to locate the resource on the Internet. It is a physical address of objects which are retrievable using protocols on the net. In other words, It is a formatted text string used by Web browsers, email clients and other software to identify a network resource on the Internet.
It consists of multiple parts including protocols, IP address, path and port to locate the information and the mechanism for retrieving it. It does not have to be HTTP URL (http://), a URL can also be (ftp://) or (smb://).
- A URL is a URI.
- A URI is not necessarily a URL.
Example of URL
1 2 |
URL: mailto:John.Doe@example.com URL: news:comp.infosystems.www.servers.unix |
What is URN?
Uniform Resource Name(URN) is a another subset of URI that identifies a resource by name. It uses the URN scheme, and does not imply availability of the identified resource.
e.g. ISBN numbers which are a good example of URN is used to identify any book uniquely.
Example of URN
1 2 |
URN (not URL): urn:oasis:names:specification:docbook:dtd:xml:4.1.2 URN (not URL): tel:+1-816-555-1212 |
Difference between URI,URL and URN
- URI is the superset of both URL and URN. All three objects are required to identify the resource on the internet.
- ALL URL and URN are URI. But a URI is not necessarily a URL or URN.
- URL uses protocol such as http:// and ftp:// to identify the resource
- URN are the unambiguous way to identify a resource. ISBN numbers are best examples of URN.