URI and URL

When you attempt to enter the vast world of the internet and web, you need to identify and locate where you are heading.

You have digital passports that help to reach your desired website or web pages. They are:

  • A unique ID for a place on the internet, kind of like coordinates on a map which is referred to as a URI.

  • The other is called a URL, which not only tells where something is. It also takes you there or shows you how to get there.

The URI

A Uniform Resource Identifier(URI) is a string of characters that uniquely identifies a particular resource. The two main types of URIs are Uniform Resource Locators(URLs) and Uniform Resource Names(URNs).

A generic URI is represented in the following format:

scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
  • Scheme: Specifies the protocol or scheme used to access the resource (e.g., "http," "https," "ftp").

  • User Info: Optionally includes a username and password, separated by a colon, for accessing a secure resource.

  • Host: Indicates the domain or IP address of the server hosting the resource.

  • Port: Specifies an optional port number to connect to on the host.

  • Path: Represents the specific location or identifier of the resource on the server.

  • Query: Contains additional parameters or data, typically used in dynamic web pages.

  • Fragment: Points to a specific section within the resource.

The URL

Look at the internet as a massive city filled with cool places and websites. A Uniform Resource Locator(URL) is the exact address that guides you to a specific spot in this digital city.

Here is the syntax of a URL:

scheme://host/path?query#fragment
  • Scheme: This is the mode of transportation you are taking. It could be "https://" for a secure website, "http://" for a regular one, or even "ftp://" for file transfers.

  • Host: Think of this as the street address. It is the domain or IP address (like www.example.com) that tells your browser where to find the website.

  • Path: This is like the specific location in a building. It guides you to a particular page or resource on the website.

  • Query: Sometimes, you need to ask for something specific. The query is like asking questions or requesting particular information. It comes after a "?" and might look like "name=John&age=15."

  • Fragment: This points you to a specific part of a page, like a particular section or paragraph. It comes after a "#" and could be something like "section3."

Example of a URL:

https://www.example.com/about?team=developers#mission
  • Scheme: "https://"

  • Host: "www.example.com"

  • Path: "/about"

  • Query: "?team=developers"

  • Fragment: "#mission"

The URN

A URN, or Universal Resource Name, is like a special and unique name given to something on the internet. It is not about its location or how to get to the location. It is more about what it is.

A URN example:

urn:isbn:1234567890
  • urn: This is saying, we are dealing with a Universal Resource Name.

  • isbn: This is the namespace, telling us the unique name is ISBN(International Standard Book Number).

  • 1234567890: This is the unique identifier assigned to the book.

When to use URI or URL

The diagram below shows when to use each of these digital passports:

When to use URI and URL

Conclusion

In conclusion, URIs are like the names that make each thing on the internet special and unique, while URLs are the addresses that tell you exactly how to find and access your favourite online places.

So, whether you're exploring the vast realms of the internet or just navigating your favourite sites, remember that behind every click and link, a URI or URL is doing its magic.

0
Subscribe to my newsletter

Read articles from Michael Adekanye directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Michael Adekanye
Michael Adekanye

Project Manager with Web Development skills with a tech stack of HTML, CSS, and JavaScript.