Protocol: In this field, you tell the browser which protocols to use, like:
- https://example.com
- http://example.com
- ftp://example.com
Subdomain: Domain can have multiple subdomains, and each subdomain can point to a different web application, like:
- https://www.example.com
- https://eservices.example.com
- https://api.example.com
Second-level Domain: This is the website domain, like:
- https://facebook.com
- https://twitter.com
- https://instagram.com
Top-level Domain: This part specifies what type of website this is, like:
- com: Usually for commercial entities
- edu: For an organization focused on education
- gov: Purposed for government entities
Port: Usually, this is needed when an uncommon port is in used, like:
- https://example.com:8080
- https://example.com:8000
- http://example.com:1234
Path: Here, you could navigate the webserver public files, like:
- https://example.com/fonts
- https://example.com/js
- https://example.com/articles
Query: This part is optional, and it comes after the question mark "?" which contain the query, and its values, like:
- https://example.com/fonts?device=desktop
- https://example.com/fonts?device=mobile
- https://example.com/articles?id=25
Fragment: This is also optional, and it comes after the hash mark "#" which tell the browsers where to go on a page, like:
- https://example.com/index.html#top
- https://example.com/index.html#middle
- https://example.com/index.html#bottom
How Browsers Protect our Data Browsers have a built-in security mechanism to prevent websites from attacking each other's called the
same-origin policy (SOP). This mechanism prevents websites and scripts from accessing data from another origin. If any of the following is changed, the browser will consider it another origin
- Protocol
- Subdomain
- Second-level domain
- Top-level domain
- Port
For example, if we have the below URL and it tries to access resources from another origin
https://example.com The table below will show SOP in action