๐ URLs, Domains & DNS
When you open a website, you usually type something like:
https://www.example.com/products
But what does each part mean?
To understand this, we need to learn three concepts:
URL โ Domain โ DNS
1๏ธโฃ What Is a URL?
URL stands for:
Uniform Resource Locator
A URL is the address used to locate a resource on the web.
For example:
https://www.example.com/products/123?color=black
A URL can contain several parts.
https://www.example.com/products/123?color=black
โ โ โ โ
Protocol Domain Path Query
Let's break it down.
2๏ธโฃ Protocol
In:
https://www.example.com
https is the protocol.
It tells the browser how communication should take place.
We've already learned about HTTPS.
You may also see:
http://
but modern websites commonly use HTTPS.
3๏ธโฃ Domain Name
In:
https://www.example.com
the domain is:
example.com
A domain name is a human-readable name used to identify a website or Internet service.
It's much easier to remember:
example.com
than an IP address such as:
93.184.216.34
We'll discuss IP addresses shortly.
4๏ธโฃ Subdomain
In:
https://www.example.com
www is a subdomain.
Other examples could be:
blog.example.com
shop.example.com
api.example.com
A company might use different subdomains for different services.
For example:
www.example.com
โ
Main website
blog.example.com
โ
Blog
api.example.com
โ
API
5๏ธโฃ Path
Consider:
https://example.com/products/123
The part:
/products/123
is the path.
It identifies the particular resource or route being requested.
For example:
/products
could represent a product listing.
And:
/products/123
could represent product number 123.
6๏ธโฃ Query Parameters
Consider:
https://example.com/products?category=shoes&sort=price
Everything after ? represents query parameters.
Here:
category=shoes
sort=price
The website can use these values to determine what information to return or how to display it.
For example:
/products?category=shoes
could mean:
Show products in the shoes category.
7๏ธโฃ Fragment
You may also see a URL such as:
https://example.com/about#contact
The part:
contact
is called a fragment.
It can identify a particular section within a page.
For example:
<h2 id="contact">Contact Us</h2>