Master the Anatomy of URLs: Essential Knowledge for Every Internet User
A URL or Uniform Resource Locator is a human readable complete address of resource like a web page on the internet. It specifies the location of the resource and how to access it. URL makes it possible for us to access anything on the internet.
Let’s understand the different parts of the URL by taking an example:
https://www.example.com:8080/path/to/resource?query=value#fragment
1. Protocol (Schema)
https://
It specifies the protocol method to access the resource. Common protocols include:
HTTP: Hypertext Transfer Protocol (non-secure).
HTTPS: Secure version of HTTP (encrypted communication).
FTP: File Transfer Protocol for transferring files.
Purpose: Defines how the browser communicates with the server hosting the resource.
2. Subdomain
www.
Subdomains are optional and represent a subsection of a domain.
Example: In
www.example.com
,www
is the subdomain.Subdomains can be custom, like
blog.example.com
orshop.example.com
.
3. Domain Name
This is the main part of the URL that identifies the website. It consists of:
Second-Level Domain (SLD):
example
Top-Level Domain (TLD):
.com
,.org
,.net
, etc.
Purpose: The domain name is registered and maps to an IP address via the DNS.
4. Port Number (optional)
:8080
A port number specifies the technical "door" through which the server listens for requests.
Default ports:
80 for HTTP.
443 for HTTPS.
Custom ports are specified when required, like
:8080
or:3000
.
Purpose: Allows servers to distinguish between different services.
5. Path
/path/to/resource
The path specifies the location of a specific resource (like a web page or file) within the domain.
- Example:
/about-us
or/products/item123
.
- Example:
Purpose: Directs the server to the requested resource.
6. Query String (optional)
?query=value
Contains key-value pairs that pass additional information to the server.
Starts with a
?
and uses&
to separate multiple parameters.Example:
?search=shoes&color=red
.
Purpose: Often used for searches, filters, or passing user data to dynamic web pages.
7. Fragment (optional)
#fragment
Refers to a specific section within the resource, often used in single-page applications or for navigation within a page.
- Example:
#section2
scrolls directly to a section of a webpage.
- Example:
Purpose: Does not involve the server; it's handled by the browser.
Is this blog helpful? Please give it a like and share it with your fellow developers to spread the knowledge!