Open In App

Difference Between URL and URI

Improve
Improve
Like Article
Like
Save
Share
Report

In Web browsers and Internet connections, it is important to understand the difference between a Uniform Resource Identifier (URI) and a Uniform Resource Location (URL). Both URIs and URLs are pointers to things like web pages, images, documents, or other online content. However, they have distinctive characteristics and functions that set them apart from one another.

What is URL (Uniform Resource Locator)? 

URL (Uniform Resource Locator) is often defined as a string of characters that is directed to an address. It provides a way to retrieve the presentation of the physical location by describing its network location or primary access mechanism. 

To locate a resource on the internet, use a Uniform Resource Locator or URL. It serves as both a resource reference and an access point. A unique resource—which could be an image, an HTML page, a CSS document, or anything else—is always displayed by a URL.

url3

URL

The protocol is described within the URL which is employed to retrieve the resource and resource name. The URL contains http/https at the start of the resource may be a web-type resource. Similarly, it begins with ftp FTPf the resource may be a file and mailto if the resource is an email address. The syntax of a URL is shown below where the primary part is employed for protocol and the remainder of the part is employed for the resource which consists of a website name or program name.

https://www.geeksforgeeks.org/minimum-cost-graph

Here, the domain name describes the server (web service) and program name (path to the directory and file on the server). 

Syntax of URL

Every HTTP URL adheres to its generic URI’s syntax. As a result, the syntax of the URL and the URI are comparable. It is provided below:

  • Scheme: A scheme is the initial part of a URL; it is a protocol that a browser must employ in order to seek a resource. HTTP and HTTPS are the protocols that are most often used for websites.
  • Authority: The domain name and port, two sub-components of the authority, are separated by a colon. The resource’s registered name, such as javatpoint.com, can be used as the domain name, and the port on a web server serves as the technical entry point to the resource. For HTTP, port 80 is used, and for HTTPS, port 443.
  • Path: The path on the web server shows the full route to the resource. A possible format is /software/htp/index.html.
  • Query String: The string containing the name and value pair is known as the query string. When it appears in a URL, the information is provided by following the path component. “?key1=value1&key2=value2” is one example.
  • Fragment: It is an optional element that comes before the hash(#) symbol. It is made up of a fragment identification that points the way to a backup resource.
  • For Ex: https://www.geeksforgeeks.org/difference-between-url-and-uri/

What is URI (Uniform Resource Identifier)?

Similar to URL, URI (Uniform Resource Identifier) is also a string of characters that identifies a resource on the web either by using location, name or both. It allows uniform identification of the resources. A URI is additionally grouped as a locator, a name or both which suggests it can describe a URL, URN or both. The term identifier within the URI refers to the prominence of the resources, despite the technique used. 

The former category in URI is URL, during which a protocol is employed to specify the accessing method of the resource and resource name is additionally laid out in the URL. A URL may be a non-persistent sort of the URI. A URN is required to exist globally unique and features a global scope.A string identifier that points to an online resource is called a URI, or uniform resource identifier. Any resource on the internet can be identified by this string of characters by either its name, its location, or both. Scheme, authority, path, query, and fragment are all contained in a URI. The most widely used URI systems include ftp, Idap, telnet, HTTPs, HTTP (Hypertext Transfer Protocol), etc.

Syntax of URI

  • Scheme: A scheme is the initial part of a Uniform Resource Locator (URI). It consists of a string of characters, which can be any combination of a letter, number, plus sign, or hyphen (_), and is followed by a colon (:). The most widely used protocols are irc, file, ftp, data, and http. It is necessary to register the schemes with IANA.
  • Authority: Two slashes (//) come before the optional authority component. There are three smaller parts to it:
    • user details: It might have a colon (:) between the username and an optional password.
    • host: It has an IP address or a registered name on it. The IP address has to be put in square brackets [] around it.
    • Path: Optional
  • Port: A series of path segments divided by a slash(/) make up this path. It is always supplied by the URI; however, the path may be null or empty.
  • Query: It is an optional element that comes before the question mark (?). It has a non-hierarchical query string with data in it.
  • Fragment: It is an optional element that comes before the hash(#) symbol. It is made up of a fragment identification that points the way to a backup resource.  

Difference Between URL and URI

URL URI
URL is used to describe the identity of an item. URI provides a technique for defining the identity of an item.
URL links a web page, a component of a web page or a program on a web page with the help of accessing methods like protocols. URI is used to distinguish one resource from other regardless of the method used.
URL provides the details about what type of protocol is to be used. URI doesn’t contains the protocol specification.
URL is a type of URI. URI is the superset of URL.
It comprises of protocol, domain, path, hash, and so on. It comprises of scheme, authority, path, query and many more.
Ex-https://www.geeksforgeeks.org/ Ex- urn:isbn:0-294-56559-3

What is a URN?

A Uniform Resource Name (URN) is a kind of Uniform Resource Identifier (URI) this is used to uniquely perceive resources at the net in a chronic and region-unbiased way. Unlike Uniform Resource Locators (URLs), which specify the location of a useful resource and how to get right of entry to it, URNs are meant to function continual, globally specific identifiers for sources irrespective of their contemporary region.

The primary reason of URNs is to provide a strong and lengthy-lasting identifier for resources, even supposing their place or access strategies trade over time. URNs are normally used for naming sources which includes documents, articles, books, and other types of virtual content.

Comparison Between URL vs URI vs URN

  • Purpose: URIs are used to perceive sources at the net, at the same time as URLs specify the area and get admission to method for getting access to sources, and URNs provide persistent, place-impartial identifiers.
  • Structure: URLs include the network location and access protocol, whilst URNs consist of a scheme and unique identifier for the resource. URIs encompass both of these systems.
  • Usage: URLs are normally used to get admission to web pages and resources without delay, whilst URNs are less normally used however provide stability and patience for useful resource identity. URIs function the overarching term that consists of each URLs and URNs.

Frequently Asked Questions on URL and URI – FAQs

Can a URL contain spaces?

Spaces are not allowed in URLs. A space is typically replaced with a plus (+) symbol or %20 in URL encoding.

What is the purpose of the query string in a URL?

URL parameters are components that are added to your URLs to assist with content organisation and filtering. They are sometimes referred to as query strings or URL query parameters.

What is the purpose of a fragment identifier in a URI?

The final, optional portion of a document’s URL is the fragment identifier that a hash mark # introduces. Usually, it is employed to designate a section of the document.



Last Updated : 26 Feb, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads