Anatomy of URL

Broken Code
4 min readMar 7, 2023

--

URL (Uniform Resource Locator) is an address of a web page. It is predominantly an instruction on how to access a resource on the internet.

Domain Name:

Domain name is the name of a website. It is the text form of the IP address. Domain name is more human friendly and easy to remember than an IP address. It would have been very difficult to remember an IP address for each site than remembering the domain name.

Domain names are typically broken up into two or three parts, each separated by a dot. The section to the right of the last dot in a domain name is the top-level domain (TLD). To the left of the TLD is the second-level domain (2LD) and if there is anything to the left of the 2LD, it is called the third-level domain (3LD) commonly known as subdomain.

For Example in example.com

  • ’.com’ is the TLD
  • ’example’ is the 2LD

and in ‘example.co.uk’:

  • ’.uk’ is the TLD
  • ’.co’ is the 2LD
  • ’example’ is the 3LD

The third-level domain (3LD) is commonly known as subdomain. However, it is to be noted that a domain is a subdomain of another domain if it is contained within that domain. For example, A.B.C.D is a subdomain of B.C.D, C.D, D, and “ “. Similarly B.C.D is a subdomain of C.D, D, and “ “. This relationship can be tested by seeing if the subdomain’s name has the containing domain’s name as the right part of its name

TLDs are divided into two categories: gTLDs (generic top-level domains) and ccTLDs (country code top-level domains).

gTLDs (generic top-level domains): .com, .edu, .mil, .net, .org etc. are some examples of generic top-level domains. Historically a gTLD was meant to tell the user the domain name’s purpose, for example:

Domain                       Purpose

com Commercial organizations

edu Educational institutions

mil Military

net Major network support centers

org Nonprofit organizations and others

ccTLDs (country code top-level domains): Country-code TLDs (ccTLDs) are reserved for use by countries, sovereign states, and territories. Some examples are .in (India), .uk (United Kingdom), .us (United States), .pk (Pakistan) etc.

The second-level domain is limited to 63 characters and can only use a-z 0–9 and hyphens. Your second-level domain (2LD) is the name of your website.

A subdomain (3LD) name has the same creation restrictions as a Second-Level Domain, being limited to 63 characters and can only use a-z 0–9 and hyphens. You can use multiple subdomains, split with periods to create longer names, such as jupiter.servers.tryhackme.com. But the length must be kept to 253 characters or less. There is no limit to the number of subdomains you can create for your domain name.

The most common subdomain is ‘www’

Protocol:

The protocol, also known as the scheme, is the first part of a URL. It represents the protocol (set of rules) used to access the resources.

HTTPS is the most common scheme.

Other schemes include HTTP, FTP, POP, SMTP, IMAP etc.

The colon ( : ) separates the scheme from the next part of the URL.

Double slash ( // )indicates that the next part of the URL is the authority.

Host:

Host represents either a hostname (domain name) or an IP address. IPV4 address must be in dotted decimal notation and IPV6 address must be enclosed in brackets [ ].

Port:

The port number is rarely visible in URLs but is always required. When declared in a URL, it comes right after the TLD, separated by a colon ( : ). When it’s not declared and protocol is http, port 80 is used. For https, port 443 is used.

Path:

The path refers to the location of the directory and a file on the server. Sometimes the file name won’t be specified, so a web browser will automatically look inside the folder for a file called index or default. If neither can be found, a 404 Not Found error will usually be returned by the server.

Query:

The question mark ( ? )is used to tell the browser that a query is being performed against a database where the data is stored.

Each query is made up of a key/value pair joined by the equals (=) sign. In case of multiple parameters, query strings are joined using the ampersand (&) sign.

http://www.example.com/path/to/file.html?key1=value1&key2=value2

Fragment:

Fragment usually appears at the end of a URL and is preceded by a hash ( # ). A fragment refers to a particular section within the same web page.

https://en.wikipedia.org/wiki/URL#Syntax

--

--

Broken Code
Broken Code

No responses yet