HACKORY
Language · English
← All chapters
HACKORY / Open library

DNS, URL and origin from scratch

A URL is the full address of something on the web, such as https://tienda.test/cuenta. DNS works like a contact list: it translates the name tienda.test into the number of the computer to connect to.

New here? Try the first lesson without an account

How it works

A URL has parts. https is the scheme, the way to connect: with https the connection is encrypted. tienda.test is the host, the site’s name. The port is a number that says which service on that computer answers; if it is missing, https uses 443. /cuenta is the path, the part of the site you ask for. What follows ? are the parameters, named values such as id=7.

Expected behavior

In https://tienda.test/cuenta?id=7, the host is tienda.test, the path is /cuenta, and the parameter id is 7.

What can go wrong

A parameter can carry another address inside it, such as destino=https://interno.test/estado. That does not change the site you opened: it is data some program may read and use later.

What to observe

Write each part separately: scheme, host, port, path, and parameters. Only then decide which computer the connection goes to.

Common false positive

A word inside the path does not become the host: in https://tienda.test/ayuda/banco.test the site is still tienda.test.

Why it matters

If you mix up the parts, you reach wrong conclusions: a word inside the path or a parameter does not change which site you are connecting to.

How to fix it

Before drawing conclusions, separate each part of the URL and ask which program reads it: your browser or the server.

Understand it step by step

Take an address apart

In https://tienda.test:443/productos?id=101 there are five parts: https is the scheme; tienda.test, the host; 443, the port; /productos, the path; and id=101, a parameter. The port is like a counter number in an office: one computer can run several services, and each one listens on a different number. You rarely see it written because https uses 443 and http uses 80 when the URL says nothing else.

What DNS does

Computers find each other by numbers, called IP addresses, such as 203.0.113.7. Since names are easier to remember, DNS acts as a contact list: you ask it for tienda.test and it gives you the number. Only with that number can the browser connect. There is a special name, localhost, that always means “this same computer”: for your browser it is your device; for a server, the server itself.

What counts as the same site

The browser groups pages by their origin: the combination of scheme, host, and port. Pages with the same origin are treated as one site; pages from another origin are kept apart so one site cannot read what another one shows. The path does not count: https://tienda.test/perfil and https://tienda.test/ayuda share an origin, but https://api.tienda.test is a different one.

Recommend this chapter to a friend