Updated: Oct 1
In this article, we will be discussing what URL is and provide details that will help you to understand the structure of any URL. By the end of this article you would be able to interpret the various part of a URL and what it means.
What is a URL?
URL stands for Uniform Resource Locator. Right from the name, it means it's a uniform way to locate a resource. A resource can be a webpage or an image, etc. To easily understand this, think of a URL as your postal mail address. From your postal code, it's easy to know the city you live in, the area of your building, where your building is and your apartment number.
Legend of a URL
- Domain Name
This is the first part of a URL. Sometimes when we type in to the browser, we ignore this part, that's okay. Scheme stands as the protocol that the browser use to request the resource. Websites usually use HTTP (unsecured) or HTTPS (secured).
The domain name is the web server that is being requested. Using the postal mail address analogy, the domain name is city you live in.
The port is the gate through which your request is passed to have access to the resource. You use port :80 for HTTP and :443 for HTTPS. You liken the port to the area in the city that you live in.
Path to the resource is targeting the location of the resource that you have requested. You can say the path is the building you live in.
Query and Parameters
In the path to find the resource you have requested, you have the location and with query, you are specifying how to find exactly what you are looking for with that resource. Parameters are the attributes specified to narrowing down the options to finding the exact resource.
More like having a mail delivered to you door step in an apartment building with your apartment number. To start a query, use ?, to join parameters, use &.
Fragments are a part of a page that you want to navigate to. You are saying on this page, I want to see this section of the page. This is where the resource you have requested is. A fragment starts with hashtag(#). With that the mail has been delivered to the person in the apartment.
Sometimes, a resource you are trying to locate might have been removed or moved somewhere else. This happens as a result of the actions of the person managing that web server. Also, you can use IP address instead of the domain name but it is easier to remember the domain name instead of the IP. You can optionally specify the port, path, query parameters and fragments if you know exactly what you are looking for in the webpage.