URL vs URI: Most important Differences You Must Know

What is the URL?

A URL is a global address of documents and protocols to retrieve resource on a computer network. URLs occur most frequently in reference to web pages (HTTP) but can also be used for database access using JDBC, email (mailto), file transfer (FTP), and many other applications. URL stands for Uniform Resource Locator.

In this URL Vs. URI tutorial, you will learn:

What is URI?

A URI is a string containing characters that identify a physical or logical resource. URI follows syntax rules to ensure uniformity. Moreover, it also maintains extensibility via a hierarchical naming scheme. The full form of URI is Uniform Resource Identifier.

Types of URI

As mention in the above figure, there are two types of URI:

  1. URL: URL specifies a location on the computer network and technique for retrieving it.
  2. URN: Uniform Resource Name (URN) is an internet resource that specifies URN scheme.

KEY DIFFERENCES:

  • URL is a subset of URI that specifies where a resource exists and the mechanism for retrieving it, while URI is a superset of URL that identifies a resource
  • The main aim of URL is to get the location or address of a resource whereas the main aim of URI is to find a resource.
  • URL is used to locate only web pages, on the other hand, URI in used in HTML, XML and other files.
  • URL contains components such as protocol, domain, path, hash, query string, etc. while, URI contains components like scheme, authority, path, query, etc.
  • Example of URL is : https://google.com while example of URI is :urn:isbn:0-486-27557-4.

Ven Diagram of URIs and URL

Ven diagram of URI and URL

As mention in the above diagram, "your name" can be a URI because it identifies you. It cannot be URL since it does not assist any person to find your home location.

On the other hand, "your home location" can be URI as well as URL. The reason is both identify you and gives a home location for you.

Syntax of URL

Here is a Syntax of URL:

http://www.domainname.com/folder-name/web page-file-name.htm

We can divide the above URL into the following parts:

Example:

This example URL has a folder but no extension

https://career.gtupapers.com/category/heavy-industries/

This example URL has no folder

https://www.gtupapers.com/what-is-sap.html

This example URL has no extension

https://career.gtupapers.com/top-33-investment-banking-interview-questions-answers/

Syntax of URI

Here is a syntax of URI:

URI = scheme:[//authority]path[?query][#fragment]

The URI includes the following parts:

  1. Optional userinfo subcomponent that might consist of a username and password (optional).
  2. A host subcomponent containing either an IP address or a registered name.
  3. An optional port subcomponent that is followed by a colon (:)

Example of URI

No protocol mentioned

www.gtupapers.com

Domain not mentioned

what-is-sap.html

Protocol mentions

ldap://[2001:db8::7]/c=GB?objectClass?one
mailto:This email address is being protected from spambots. You need JavaScript enabled to view it. 
tel:+1-816-555-1212   
telnet://192.0.2.16:80/ 

Confusion about URN

There is a confusion about URN that, if you implement protocols like https, ftp, etc, then it is called a URL, even though it is a URI.

The problem with such a debate is that appropriate RFC are extremely dense and sometimes even contradictory. For example, RFC 3986 says, URI can be either a name, locator or both.

Why URL?

Here are the important reasons of using URL:

Why URI?

Here are the important reasons of using URI:

URL Vs. URI

Here are the main differences between URL and URI:

URL URI
URL stands for Uniform Resource Locator. URI stands for Uniform Resource Identifier.
URL is a subset of URI that specifies where a resource is exists and the mechanism for retrieving it. A URI is a superset of URL that identifies a resource either by URL or URN (Uniform Resource Name) or both.
The main aim is to get the location or address of a resource The main aim of URI is to find a resource and differentiate it from other resources using either name or location.
URL is used to locate only web pages Used in HTML, XML and other files XSLT (Extensible Stylesheet Language Transformations) and more.
The scheme must be a protocol like HTTP, FTP, HTTPS, etc. In URI, the scheme may be anything like a protocol, specification, name, etc.
Protocol information is given in the URL. There is no protocol information given in URI.
Example of URL: https://google.com Example of URI: urn:isbn:0-486-27557-4
It contains components such as protocol, domain, path, hash, query string, etc. It contains components like scheme, authority, path, query, fragment component, etc.
All URLs can be URIs Not all URIs are URLs since a URI can be a name instead of a locator.

 

YOU MIGHT LIKE: