As a developer, you’ve probably heard urls a million times. You’ve probably encountered URIs before, and now you want to know what the difference is between them (if there is one). The two are often used interchangeably, but we have to distinguish between the two. Let’s look at the definition of each of them before we compare.
What is a URL?
A Uniform Resource Locator, or URL– as the name suggests — is a reference to a Resource and a way to access it. It is often referred to as the site’s address, the one found in the address bar.
The URL consists of several different parts:
- Agreement: Usually
https
orhttp
. A way to access resources, you can also see other protocols in the past, for exampleftp
orfile
- Then there is
: / /
- Host name: A registered name or IP address used to identify devices connected to the network.
- This is followed by an optional port starting with a colon
- Path: This can reference file system paths, but is also often used as slug
- Optional query parameters beginning with a question mark, where multiple parameters are concatenated with &
- Fragment: An optional fragment that begins with a hash. It is used to provide quick links to titles on the page
For illustration purposes, the URL is shown in the diagram below:
What is a URI?
Now that you fully understand how urls are put together, let’s take a look at what a URI is. Like urls, URIs (Uniform Resource Identifiers) provide a way to identify resources, but unlike urls, they do not necessarily provide a way to locate said resources.
An example of a URI (not a URL) is an ISBN number used to identify a book, which uses a unique encoding to clearly identify the resource, but it does not provide any means of actually accessing the resource.
We can therefore conclude that URIs are supersets of urls, and that each URL is essentially a URI.
Differences in graphic
To illustrate the connection, take a look at the following image:
A URL is actually a URI that also contains information about how to access a resource. If there was only one thing to learn in this tutorial, it would be thatRFC396In a sentence:
The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism(e.g., its network "location").
conclusion
As Web developers, we have to remember a lot of acronyms and acronyms. The deeper you understand the core concepts of how the Internet works, the easier it will be, the better your work will be, and the more knowledgeable you will be.
With this tutorial, you now know the difference between A URI and a URL. If you still have any questions, please don’t hesitate to ask them in the comments section. Thanks for reading and have fun coding!
Address:
Medium.com/weekly-webt…