URI vs URL

We offer you a brighter future with FREE online courses - Start Now!!

In this article, we will learn what is URI, what is URL and URI vs URL. Let’s start!!!

What is a URI?

A URI, or Uniform Resource Identifier, is a string identifier that refers to an internet resource. It is a string of characters used to identify any resource on the internet based on its location, name, or both.

A URI has two subsets: URL (Uniform Resource Locator) and URN (Uniform Resource Name) (Uniform Resource Number). If it only contains a name, it is not a URL. In the real world, we mostly see URLs and URNs rather than direct URIs.

HTTP, HTTPs, ftp, Idap, telnet are common URI schemes.

URI Syntax:

1. Scheme:

Scheme can be any combination of letter, digit, plus sign, or hyphen (-), followed by a colon (:). The most common protocols are http, file, ftp, data, and irc. The schemes must be registered with the Internet Assigned Numbers Authority (IANA).

2. Authority:

The authority component is optional and is denoted by two forward slashes (/).

  • userinfo: It may include a username and, optionally, a password separated by a colon. The @ symbol comes after the sub-component.
  • host: It either has a registered name or an IP address. The IP address must be surrounded by [] brackets.
  • port: Optional

3. Path:

It is made up of a series of path segments separated by a slash(/). It is always specified by the URI; however, the specified path may be empty or of 0 length.

4. Query:

It is an optional component, denoted by a question mark (?). It contains a non-hierarchical query string.

5. Fragment:

It is also an optional component that is preceded by the hash(#) symbol. It is made up of a fragment identifier that points to a secondary resource.

Example of URI: news:comp.infosystems.www.servers.unix

What is a URL?

A URL, or Uniform Resource Locator, is used to locate a resource on the internet. It is a resource reference as well as a method of accessing that resource. A URL always represents a unique resource, which could be an HTML page, a CSS document, an image, or something else.

A URL accesses a resource via a protocol, which can be HTTP, HTTPS, FTP, or others.

It is primarily referred to as the website’s address, which a user can find in their address bars.

URL Syntax:

1. Scheme:

The first component of the URL is a scheme, which represents a protocol that a browser must use to request the resource. HTTP or HTTPS are the most commonly used protocols for websites.

2. Authority:

The authority consists of two sub-components, separated by a colon: domain name and Port. The domain name can be anything, and the port is the technical gate through which the resource is accessed on a web server. HTTP is accessed via port 80, while HTTPS is accessed via port 443.

3. Path:

The path specifies the full path to the web server resource. It could be something like /software/htp/index.html.

4. Query String:

The name and value pair are contained in the string. When used in a URL, it follows the path component and provides the information. For example, “?key1=value1&key2=value2”.

5. Fragment:

It is also an optional component that is preceded by the hash(#) symbol. It is made up of a fragment identifier that points to a secondary resource.

Difference between URI vs URL:

1. URI contains both URL and URN to identify a resource’s name and location or both; URL, on the other hand, is a subset of URI and only identifies the resource’s location.
2. The URI example is urn:isbn:0-476-27557-4, while the URL example is https://google.com.
3. We can use URI to locate resources in HTML, XML, and other files, whereas we can use URL to find a web page.
4. Each URL can be a URI, but not all URIs can be URLs.

Comparison between URI and URL:

URIURL
URI is an abbreviation for Uniform Resource Identifier.The term URL is short for Uniform Resource Locator.
URN, which tells the name, and URL, which tells the location, are two subsets of URI.URL specifies the resource’s unique location, and is a subset of URI.
All URIs cannot be URLs because they can indicate either a name or a location.Because every URL can only contain the location, all URLs are URIs.
A URI attempts to identify and distinguish a resource from other resources by using the resource’s name or location.A URL seeks to locate or address a resource on the internet.
ISBN 0-486-35557-4 is an example of a URI.https://data-flair.training/ is an example of a URL.
It identifies resources and binaries in XML and tags library files such as JSTL and XSTL.It is useful to search the internet for web pages.
A URI scheme can be a protocol, a designation, a specification, or anything else.The URL scheme is typically a protocol such as HTTP, HTTPS, FTP, and so on.

Summary:

In this article, we looked at the concept of URI and URL, and also the syntax of each. We looked at the differences between URI and URL, and also a tabular comparison between URI and URL.

Your opinion matters
Please write your valuable feedback about DataFlair on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *