Lesson 3 / الدرس 3

The URL and its parts / العنوان وأجزاؤه

An address is not one thing. It is six, and each is read by a different part of the journey — one by the browser, one by DNS, one by the server, and one that never leaves your machine at all.

العنوان ليس شيئًا واحدًا. بل ستة، ويقرأ كل واحدًا منها جزء مختلف من الرحلة — واحد للمتصفح، وواحد لـ DNS، وواحد للخادم، وواحد لا يغادر جهازك إطلاقًا.

The first step of the journey is the browser reading what you typed. A full address — a URL — is a small structured sentence, and each part is an instruction to a different participant. Learning the parts is what lets you read an address and predict what will happen.

The six parts

https://training.gt4it.com:443/lesson/web/the-url?page=2#parts
└─┬─┘   └───────┬────────┘ └┬┘└────────┬───────┘└──┬──┘└─┬─┘
  │             │           │          │           │     └ fragment
  │             │           │          │           └────── query
  │             │           │          └────────────────── path
  │             │           └───────────────────────────── port
  │             └───────────────────────────────────────── host
  └─────────────────────────────────────────────────────── scheme
Six parts. Two of them you usually never type: the port has a default (443 for https, 80 for http), and the fragment is optional.
  • Scheme — which protocol to speak. https means "HTTP, encrypted". Read by the browser.
  • Host — which machine. This is the only part DNS ever sees.
  • Port — which door on that machine. Defaulted, so rarely typed.
  • Path — what you want from that machine. Sent to the server.
  • Query — extra named values after a ?, joined by &. Also sent to the server.
  • Fragment — everything after #. Handled entirely by the browser and never sent anywhere.

What is sent, and what is not

<a href="/lesson/web/dns">a path on this host</a>
<a href="?page=2">the same page, a different query</a>
<a href="#bottom">a fragment — no request at all</a>
The third link is the interesting one. Clicking it sends nothing to any server: the browser simply scrolls. That is why the anchors lesson in the HTML course worked without a round trip, and why a fragment can never be read by the site you are visiting.
PartRead bySent to the server?
schemeThe browserNo — it decides how to connect
hostDNS, then the connectionYes, as the Host header
portThe connectionNo
pathThe serverYes
queryThe serverYes — and it is logged
fragmentThe browser onlyNever

Who reads what. The last row is the one people get wrong.

Try it live / جرّب بنفسك

Preview / المعاينة

Check yourself / اختبر نفسك

1. Which part of a URL is never sent to the server?

2. Why should a password never go in the query string?

3. In https://example.com/shop?id=7, which part does DNS look up?

Your task / مهمتك

Take a long URL from a site you use — a search result or a product page — and break it into its parts on a page, labelling each one and saying who reads it. Then write one sentence on what the query values appear to mean.

خذ عنوانًا طويلًا من موقع تستخدمه — نتيجة بحث أو صفحة منتج — وقسّمه إلى أجزائه في صفحة، وسمِّ كل جزء وقل من يقرؤه. ثم اكتب جملة واحدة عمّا يبدو أن قيم الاستعلام تعنيه.

  • Every part present in the URL is labelled كل جزء موجود في العنوان مسمّى
  • Each label says who reads that part كل تسمية تقول من يقرأ ذلك الجزء
  • A sentence explains what the query values seem to do جملة تشرح ما يبدو أن قيم الاستعلام تفعله
How do you want to submit? / كيف تريد التسليم؟