Course එකට ආපසු

URLs Decoded

10 මිනිත්තු📖Lecture

🎯 Lesson Objectives

By the end of this lesson, you will:

  • Understand every part of a URL
  • Read URLs and know what to expect before clicking
  • Recognize suspicious or malformed URLs
  • Understand how URLs map to resources

📖 What is a URL?

URL stands for Uniform Resource Locator.

In Plain English

A URL is the address of something on the internet.

Just like your home address tells mail carriers where to deliver packages, a URL tells browsers where to find a specific webpage, image, file, or resource.


🔍 Anatomy of a URL

Let's break down a complete URL:

Text
https://www.example.com/shop/shoes?color=red&size=10#reviews
│ │ │ │ │ │ │
│ │ │ │ │ │ └─ Fragment
│ │ │ │ │ └─ Query Parameters
│ │ │ │ └─ Path (continued)
│ │ │ └─ Path
│ │ └─ Domain
│ └─ Subdomain
└─ Protocol

🔒 Protocol: https://

What It Is:

The protocol tells your browser HOW to communicate with the server.

Common Protocols:

ProtocolMeaningSecurity
https://HyperText Transfer Protocol Secure✅ Encrypted
http://HyperText Transfer Protocol❌ Not encrypted
ftp://File Transfer ProtocolFor file downloads
mailto:EmailOpens email app

Security Tip

Always look for https:// when entering sensitive information (passwords, credit cards). The 's' means 'secure' — your data is encrypted.

Most browsers show a 🔒 padlock icon for HTTPS sites.


🏠 Domain: example.com

What It Is:

The domain is the name of the website — like the restaurant's name.

Examples:

  • google.com
  • youtube.com
  • amazon.com
  • github.com

Structure:

Text
example.com
│ │
│ └─ Top-Level Domain (TLD)
└─ Domain Name

Common TLDs:

TLDTypical Use
.comCommercial (most common)
.orgOrganizations
.eduEducational institutions
.govGovernment
.ioTech startups
.netNetwork services
.co.ukUnited Kingdom

🏢 Subdomain: www.

What It Is:

A subdomain is a section of the main domain — like a department within a company.

Examples:

  • www.example.com — www is a subdomain (traditional)
  • mail.google.com — Gmail service
  • docs.google.com — Google Docs
  • maps.google.com — Google Maps
  • blog.example.com — A company's blog

Fun Fact

www is just a convention. example.com and www.example.com usually point to the same place.


📁 Path: /shop/shoes

What It Is:

The path specifies WHICH page or resource you want — like a folder structure.

Examples:

example.com/ → Home page example.com/about → About page example.com/products → Products page example.com/products/shoes → Shoes category example.com/products/shoes/nike → Nike shoes specifically

Folder Analogy:

Text
Website/
├── about/
├── products/
│ ├── shoes/
│ │ └── nike/
│ └── shirts/
└── contact/

❓ Query Parameters: ?color=red&size=10

What It Is:

Query parameters send extra information to the server — like special instructions with your order.

Structure:

Text
?key1=value1&key2=value2&key3=value3
│ │ │
│ │ └─ & separates multiple parameters
│ └─ = connects key to value
└─ ? starts the query string

Examples:

google.com/search?q=cats └─ q (query) = cats youtube.com/watch?v=abc123 └─ v (video) = abc123 amazon.com/products?category=electronics&sort=price └─ Multiple parameters

Common Uses:

  • Search queries (?q=search+term)
  • Filters (?color=blue&size=large)
  • Sorting (?sort=price&order=asc)
  • Pagination (?page=2)

🎯 Fragment: #reviews

What It Is:

The fragment (also called anchor or hash) tells the browser to jump to a specific section of the page.

Examples:

example.com/article#introduction → Jump to intro example.com/article#chapter-2 → Jump to chapter 2 example.com/article#conclusion → Jump to conclusion

Technical Note

Fragments are handled entirely by the browser — they're NOT sent to the server.


🔬 Let's Practice: URL Breakdown

URL 1: YouTube Video

Text
https://www.youtube.com/watch?v=dQw4w9WgXcQ
PartValueMeaning
ProtocolhttpsSecure connection
SubdomainwwwStandard web
Domainyoutube.comYouTube's website
Path/watchVideo watching page
Queryv=dQw4w9WgXcQVideo ID to play

URL 2: Amazon Search

Text
https://www.amazon.com/s?k=laptop&ref=nb_sb_noss
PartValueMeaning
ProtocolhttpsSecure
Domainamazon.comAmazon
Path/sSearch page
Query klaptopSearch keyword
Query refnb_sb_nossTracking info

⚠️ Spotting Suspicious URLs

Red Flags to Watch For

Suspicious PatternExampleWhy It's Bad
Misspelled domainsgo0gle.com, amazom.comPhishing attempt
Extra subdomainslogin.google.secure.fakesite.comFake site
HTTP (not HTTPS)http://yourbank.comInsecure connection
IP address instead of domainhttp://192.168.1.1/loginSuspicious
Very long, encoded URLs%2F%3D%26...May hide malicious content

Legitimate:

https://accounts.google.com/signin

Suspicious:

http://accounts.google.com.fake-login.com/signin ↑ This is actually fake-login.com!

🔐 URL Security Checklist

Before Entering Sensitive Info:

0/4

✅ Lesson Summary

URL PartSymbolPurposeExample
Protocol://How to connecthttps://
Subdomainbefore domainSite sectionwww., mail.
Domain.com, .org, etc.Site identitygoogle.com
Path/Which page/search/images
Query? and &Extra parameters?q=cats&safe=on
Fragment#Page section#chapter-2

📝 Mini Quiz

📝 Check Your Understanding

1/3

In https://www.youtube.com/watch?v=abc123, what is 'youtube.com'?