Destructuring the URL (Uniform Resource Locator)
Visiting a physical location is straightforward, but how do you access a website in a browser? We use a URL, or Uniform Resource Locator, but what exactly is a URL? In this article, we’ll explore URLs and break them down step-by-step to gain a deeper understanding.
Understanding Physical & Digital Addresses
Let’s consider an example: you have the address of your home, workplace, or a relative’s house. Do you refer to these places by their addresses? No, you usually call them by a name, like “Mark’s House,” and then look up the exact address in your address book. Nowadays, we use Google Maps to store someone’s precise location and get directions to it. But how does this relate to a URL?
A URL works in much the same way. In a browser, we enter a URL in the address bar, but these URLs are actually domain names that correspond to Internet Protocol (IP) addresses, managed by a Domain Name System (DNS) server. For example, would you visit the DevNur website using the URL devnur.com or by typing in its IP address 86.38.202.105? Naturally, you’d use the URL because it represents the domain name, which is the website’s address.
Breaking up the URL
To an average person, a URL is just a piece of text, but for a backend developer, network engineer, or anyone technically involved, it’s important to understand how URLs are structured, as they deal with them daily. So, let’s break down the components of a URL.
In the diagram above, we used the URL https://blog.devnur.com/posts as an example to illustrate the concept, even though it’s not an actual URL. Let’s break down this URL and examine each of its components to understand them better.
- Scheme
- Subdomain
- Second level-domain
- Top level-domain
- Subdirectory
Scheme
Currently, the language of the World Wide Web (WWW) is the HyperText Transfer Protocol (HTTP) or its secure version, HyperText Transfer Protocol Secure (HTTPS), which is referred to as the scheme in a URL. These protocols handle the transfer of data over a network to a web server. HTTPS is an enhanced version of HTTP, providing added security by encrypting data before it’s transmitted over the network.
Subdomain
Subdomains are similar to containers in a container yard, where the container yard represents the root domain and each container represents a subdomain. For instance, in our example, the URL uses “blog” as a subdomain, but there could also be others like dashboard.devnur.com or store.devnur.com. Subdomains are optional and help organize your website into different sections based on specific modules, making it easier to manage and access.
Modern browsers attempt to simplify URLs by omitting unnecessary parts, such as “www,” which is also considered a subdomain. However, ignoring “www” does not mean it is included or excluded; its use is entirely dependent on the configuration of the web server.
Second Level Domain
A second-level domain (SLD) is a fundamental part of a URL and is considered part of the root domain. In our example, the term “devnur” is the second-level domain and serves as the unique identifier of the website. Typically, second-level domains represent a brand or product name. They are chosen and purchased along with their associated subdomains and top-level domains.
Top Level Domain
Top-level domains (TLDs) are another essential component of a URL. When combined with the second-level domain, they form the root domain. In the diagram above, “.com” is the TLD, which stands for “commercial.” There are many other TLDs, such as “.net” (network), “.org” (organization), “.cc” (carbon copy), and more. The “.com” TLD is the most popular because it is widely associated with professionalism and credibility.
Subdirectory
A subdirectory in a URL is the path that follows the root domain (comprising the second-level domain and top-level domain). In the diagram above, the subdirectory “/posts” indicates that we are on a page dedicated to posts. This helps both users and web crawlers understand the specific page they are visiting. While there is no limit to the number of subdirectories you can create, it’s best to keep them well-organized and manageable.
URLs are essential, and every software engineer should grasp their basic components. There’s much more to explore about URLs, such as the benefits of using HTTPS over HTTP, the significance of omitting “www,” Internet protocols, and more. For now, I hope you have gained a basic understanding of URLs and their elements.