In this tutorial, we will explore and compare features of URL Vs URI and learn various key differences between URL and URI with examples:
The web world is loaded with information. Information is meaningful and useful if it is accessible on time easily. Uniform Resource Identifier (URI), Uniform Resource Locators (URL), and Uniform Resource Names (URN) facilitates this.
What You Will Learn:
Understanding URL Vs URI Vs URN
URL is a string of characters that not only identifies the resource located on the Internet but also gives the mechanism to reach the location and retrieve the data. Example: https://www.Amazon.com
URI is a string of characters that identifies a resource on the web by its name, address/location, or both.
URN is a string of characters that gives the name of the resource. It gives a unique identity of a resource within a defined area or namespace. Example: ISBN:0-486-27557-4
Is URI the Same As URL
URI is all-encompassing as it can identify a resource by location (URL), by name (URN), or both. URL and URN are subsets of URI.
URI and URL are often used interchangeably. They are related, but they indicate and give information about different things. There are subtle differences in the objective and purpose served by the two. URL is always a URI, but the reverse is not true. URI may or may not be a URL.
For example, Telephone no is a URI – Tel:+1-854-343-1222. It identifies a resource, i.e. a telephone. URI resource identified need not always be a web resource. It can be any real-world object like a person, a document, an object, etc. A book identified by using an ISBN number uniquely is an example of URN, which is a subset of URI.
If there is an ambiguity in identifying if a given string is a URI or URL, then it is better to mark it as a URI, as all URLs are URIs.
URI and URL diagrammatic representation:
Difference Between URL And URI
|Full form of URL is Uniform Resource Locator||Full form of URI is Uniform Resource Identifier|
|URL is used to navigate or link to a component of a web page with the help of the accessing technique mentioned in the URL.||URI defines the identity of a resource and establishes the unique distinguished identity of the resource regardless of the method used (name, location or both)|
|It is the subset of URI.||It is the superset of URL.|
|URL is always a URI||A URI may not be a URL if it mentions only the name and no location|
|It identifies a resource by its location||It identifies a resource by name, location or both|
|URL identifies the resource on the web or the internet||URI identifies a resource which may or may not be in the web (like a book by its ISBN number)|
|URL always mentions the protocol to retrieve the resource||URI may have the protocol or named space or just a name like a telephone number is a URI but not a URL.
|Example: https://www.travel.com||Example: URN:ISBN:0-452-12776-411133|
|URL components are protocol, domain, path, port, fragment, query string, etc.||URI components are scheme, authority, path, query, fragment, unique name etc.|
|URL protocol facilitates navigation to a web page, component or section of a web page||URI mainly distinguishes one resource from the other and may have all the details mentioned in a URL or just the distinguishing name of the resource|
Frequently Asked Questions
Q #1) What is a good URI?
Answer: A good URI should be self-explanatory and should establish the identity of the resource clearly. URI should have a hierarchical structure that will help to establish the identity of the resource and also help in retrieving the resource from the location.
Q #2) What are the uses of URLs?
Answer: URL is generally used to connect or link to web pages or specific sections of a webpage, i.e. HTTP. They are also used for other purposes, and the protocol establishes the purpose. URL for file transfer will have protocol FTP, for email it is mailto, for database access it is JDBC, etc.
Q #3) Give an example of a URL for protocol and resource?
Answer: http://www.example.com is an example of a URL, where HTTP is the protocol, and the resource is www.example.com.
Q #4) How to get a URL of a page?
Answer: The first step is to Google search the desired page and click on the link to open the page. The browser’s address bar at the top of the page will give the URL of the page. Copy the same and open a new window with the copied URL in the address bar. This will open the specific page.
Q #5) Identify URL and URI from below?
- www.mysite.com: None. It is a domain name. It is not a URL as it does not have a protocol and is not a URI as it does not give a unique identification of a resource either.
- http://www.mysite.com: Both URL and URI, as it gives the location and access protocol.
- data:,Hello%20World: Data URI. It is not a URL, as it does not give the location of the source. It’s a data URI as it starts with a data scheme and is for including inline data.
Q #6) What is the main difference between URL vs URI?
Answer: URI is a resource identifier and it can identify any resource like a document, web page, image, book, etc. URL is a subset of URI and it identities the resource by its location and also gives the mechanism to retrieve the resource from the location.
Suggested Reading =>> URL And URN – Understanding The Key Difference
Uniform Resource Locator (URL) and Uniform Resource Name (URN) are both types of Uniform Resource Identifier (URI). URI has a broader framework and encompasses both URN and URL. URI can be used in a general context for both URL and URN.
URL and URN are subsets of URI and have different objectives and purposes in identifying a resource. The difference between URI and URL is very fine and subtle. URI detailing a location is a URL whereas a URI detailing just the name of the resource is a URI but not a URL.
URL and URI are the keys to reach and access the information on the Internet and connect to different sites for information. The significance of the two in today’s digital world can be gauged by the statement made by Stephen Hawking –
“We are all now connected by the Internet, like neurons in a giant brain”