URL Anatomy: Every Part of a Web Address
Take a web address apart piece by piece, learn what each part does and spot the tricks that disguise where a link leads.
Key takeaways
- The general shape is
scheme://host:port/path?query#fragment, and most parts after the host are optional. - The registered domain at the right end of the hostname shows who controls the address.
- The fragment after
#stays in the browser and is not sent to the server. - Characters with special meanings must be percent-encoded when they are part of the data.
- Query strings are recorded in history and logs, so they are a poor place for secrets.
A URL, or Uniform Resource Locator, tells software how to reach something and which thing you want. Read from left to right, it names a scheme (how to talk), a host (whom to talk to), sometimes a port, then a path, a query string and a fragment that narrow down what you are after.
Knowing the parts helps you build clean links, debug broken ones and, most usefully, tell where a suspicious link really goes. The key habit is finding the hostname and reading it from the right.
One address, taken apart
The generic syntax comes from RFC 3986. Browsers follow a closely related living specification from the WHATWG that also defines how to cope with sloppy input. You may see the term URI, a Uniform Resource Identifier, which is the broader category. In everyday use the two words overlap.
The scheme
The scheme comes before the first colon. https means HTTP over TLS, and http means the same protocol unencrypted. Others include mailto: for email addresses, tel: for phone numbers, ftp: for the old file transfer protocol, file: for local files and data:, which carries the content inside the address itself.
Not every scheme uses //. The double slash introduces an authority, meaning a host and its companions, which mailto:[email protected] does not have.
Apps can register their own schemes, so clicking an unfamiliar one may launch a program on your device. Browsers usually ask first.
The authority: host, port and user info
The authority can hold three things: user@host:port.
The host is a domain name or an IP address. IPv6 addresses go in square brackets, because their colons would otherwise be confused with the port: https://[2001:db8::10]:8443/.
The port defaults to 443 for https and 80 for http. Browsers hide the default. Ports explained covers how one machine offers many services.
The user info before an @ is a leftover that browsers now restrict or warn about. It is mainly of interest because it misleads: in https://[email protected]/login, the part that looks like a site name is only a username, and the real host is 192.0.2.44.
Reading a hostname
Domain names are read from the right. In shop.example.co.uk:
-
ukis the top-level domain. -
co.ukis a suffix under which people register names. -
example.co.ukis the registered domain, controlled by one registrant. -
shopis a subdomain, which that registrant can name freely.
This matters for safety. In www.example.com.account-check.example.net, the controlling domain is example.net. Everything to the left is decoration that its owner chose. See subdomains vs. subdirectories for how site owners use these levels.
Hostnames are not case-sensitive. They may contain non-English characters, which are converted to an ASCII form beginning xn-- for DNS. Letters from different alphabets can look identical, which the IDNA label inspector and the article on look-alike characters help expose.
How to check a link
A padlock or https shows that the connection is encrypted to that hostname. It says nothing about whether the owner is honest. Phishing pages use HTTPS routinely. When in doubt, type the address you already know or use a saved bookmark. How to spot a phishing email has more signs.
Shortened links and tracking redirects hide the destination until followed. Treat unexpected ones with the same caution.
The path
The path begins at the first slash after the authority. It looks like folders and files, but the server may map it to anything: a database record, a program or a generated page.
Paths are case-sensitive as far as the standard is concerned, although some servers ignore case. /Guide and /guide may be two pages or one. A trailing slash can also make a difference. Sites benefit from picking one form and redirecting the others, so that links and search engines agree on a single address.
Segments . and .. mean "here" and "one level up". Browsers resolve them before sending the request.
The query string
Everything after ? up to any # is the query. By convention it holds name=value pairs joined by &:
https://www.example.com/search?q=mesh+wifi&sort=new&page=2 Servers define what the names mean. Order usually does not matter to the application, but caches may treat different orders as different addresses.
Marketing links often add utm_ parameters that record where a click came from, and some services append unique identifiers. Removing them generally still loads the page, though not always. The query parameter editor makes long strings readable.
The fragment
The part after # points within the resource, usually to a heading or element with a matching ID. The browser keeps it to itself: it is not included in the HTTP request. Single-page applications sometimes use fragments for navigation for exactly that reason.
Some browsers also support text fragments, which highlight a quoted phrase on the destination page.
Percent-encoding
URLs allow a limited set of characters. Others are written as % followed by two hexadecimal digits for each byte, usually of the UTF-8 encoding.
| Character | Encoded | Why it needs it |
|---|---|---|
| space | %20 | Not allowed in a URL |
& | %26 | Otherwise separates parameters |
# | %23 | Otherwise starts the fragment |
? | %3F | Otherwise starts the query |
% | %25 | Otherwise starts an escape |
é | %C3%A9 | Two bytes in UTF-8 |
In form-style query strings, a space is often written as +, so a real plus sign must be %2B. URL encoding explained covers the rules, and the URL encoder and inspector shows them live.
Encoding twice is a classic bug: %20 becomes %2520. If you see %25 where you did not expect it, something encoded already encoded text.
Relative and absolute URLs
An absolute URL has a scheme and works anywhere. A relative one is resolved against the current page. From https://www.example.com/docs/setup/intro.html:
| Written | Resolves to |
|---|---|
next.html | https://www.example.com/docs/setup/next.html |
../faq.html | https://www.example.com/docs/faq.html |
/contact | https://www.example.com/contact |
//cdn.example.com/a.js | https://cdn.example.com/a.js |
?page=2 | https://www.example.com/docs/setup/intro.html?page=2 |
A missing leading slash is behind many links that work on one page and break on another.
What reaches the server
It helps to know which parts travel where. Take this address:
https://shop.example.com:8443/guides/routers?sort=new#setup The browser uses the pieces in stages:
- The host goes to DNS to find an IP address.
- The scheme and port decide that it connects to port 8443 and sets up TLS.
- The hostname is offered during the TLS setup so the server can choose a certificate.
- The request itself carries the path and query,
/guides/routers?sort=new, along with aHostheader ofshop.example.com:8443. - The fragment,
setup, is applied by the browser after the page arrives.
Who can see what differs too. With HTTPS, someone watching the network can learn the server's IP address and port, and often the hostname from DNS or the TLS setup, but not the path or query. The website sees all of it except the fragment, though scripts running on its page can read the fragment as well. Your own browser history keeps the whole thing.
When a visitor follows a link elsewhere, the browser may send the previous page's address in a Referer header. Common default policies trim it to just the origin for other sites, but a site can choose to send more.
Sharing and cleaning links
Before you paste a long link into a chat or a document, glance at its query string. Some parameters are needed, such as a product number or a search term. Others record the campaign that brought you there, and a few may be tied to your account or session.
Try removing the extras and loading the result in a private window. If the page still appears and you are not mysteriously signed in, share the short form. If a link grants access to a file or meeting by itself, remember that anyone who receives it, or finds it in a forwarded message, can use it until it expires or is revoked.
QR codes are URLs in picture form. Most phone cameras show the address before opening it, so apply the same hostname check there.
Designing good URLs
For your own site:
- Keep paths short and readable, using words that describe the page.
- Use lowercase and hyphens between words.
- Choose one hostname and one trailing-slash style, and redirect the rest.
- Keep addresses stable, and when one must change, add a permanent redirect.
- Never put passwords, reset secrets with long lifetimes or personal data where logs and referrer headers can spread them.
Very long URLs can fail. The standard sets no single maximum, but browsers, servers and proxies each have limits, and a server that refuses one answers 414 URI Too Long. Large inputs belong in a request body.
Common questions
Is www necessary?
No. www is just a subdomain. A site can use it or the bare domain, as long as one redirects to the other consistently.
What happens when I type a name without https?
The browser fills in a scheme and may try HTTPS first, or it may treat your text as a search. The full journey is described in what happens when you press Enter.