Skip to content
Urlzee

Anatomy of a URL: Every Part Explained with Examples

By Urlzee Team · Published · 6 min read

A URL is built from up to six parts in a fixed order: a scheme, a host, an optional port, a path, an optional query string and an optional fragment. Each part answers a different question: how to connect, which computer to ask, what to ask for, with what extra details, and where on the page to land.

What are the parts of a URL?

Here is one address that contains every part, followed by a breakdown.

https://shop.example.com:443/garden/chairs?colour=oak&sort=price#reviews
PartIn the exampleRequired?What it does
SchemehttpsYesSays which protocol to use
Hostshop.example.comYes, for web URLsNames the server
Port443NoPicks a network port on that server
Path/garden/chairsCan be emptyIdentifies the resource
Querycolour=oak&sort=priceNoSupplies parameters
FragmentreviewsNoPoints to a place within the resource

The punctuation between the parts is fixed: :// after the scheme, : before the port, / to start the path, ? to start the query and # to start the fragment. Those characters are how software tells where one part stops and the next begins. The formal grammar is defined in RFC 3986.

What is the scheme?

The scheme is the first part of the URL and names the protocol the browser should use. For web pages it is http or https. The s means the connection is encrypted with TLS, so the content cannot be read or altered in transit.

Other schemes exist. mailto: opens an email draft, tel: starts a phone call, and file: refers to a file on your own device. Not all of them use the // that web addresses do: mailto:hello@example.com is a valid URL.

Scheme names are not case sensitive, though they are written in lowercase by convention.

What is the host, and how do subdomains fit in?

The host names the server that will answer the request. It is read from right to left, from the most general label to the most specific.

Take shop.example.com:

  • com is the top-level domain (TLD).
  • example is the name registered under that TLD. Together, example.com is what people usually call the domain.
  • shop is a subdomain, created by whoever controls example.com.

www is simply a subdomain that became conventional. www.example.com and example.com are technically different hosts, which is why sites redirect one to the other.

Reading right to left is a practical security skill. In example.com.account-verify.net, the registered domain is account-verify.net, not example.com. Whatever sits immediately before the first single slash is the real host, and its rightmost labels tell you who owns it. How to spot a phishing link shows how attackers exploit this.

A host can also be an IP address, such as 192.0.2.10. Hostnames are not case sensitive.

What is the user info part?

Occasionally a URL has text and an @ sign before the host: https://user@example.com/. This is the user info component, once used to pass a username. It is rare on legitimate sites and is discouraged, but it matters for safety: in https://example.com@evil.example/, the host is evil.example. Everything before the @ is ignored for the purpose of deciding which server to contact.

What is the port?

The port is a number that selects a specific service on the server. You rarely see it because each scheme has a default: 80 for http and 443 for https. When the default applies, browsers leave it out.

You will see explicit ports in development and on internal tools, such as http://localhost:3000/.

What is the path?

The path identifies which resource you want from the server. It starts at the first single slash after the host and is divided into segments by further slashes: /garden/chairs.

Paths look like folders and files because, on early web servers, they were. Today a path is more often a label that the site's software maps to content. A few details cause trouble:

  • Case. Many servers treat /Chairs and /chairs as different paths.
  • Trailing slash. /garden and /garden/ can be different resources. Sites normally redirect one form to the other.
  • Empty path. https://example.com and https://example.com/ are equivalent; the browser requests /.

On a short link, the path is the whole point. In https://urlzee.com/open-day, the path /open-day is the alias the URL shortener looks up to find the destination.

What is the query string?

The query string carries extra parameters for the request. It begins with ? and is conventionally written as name=value pairs joined by &:

?colour=oak&sort=price

Here colour has the value oak and sort has the value price. The server or the page's scripts decide what to do with them: filter products, run a search, choose a language.

Campaign tracking uses the query string too. UTM parameters such as utm_source=newsletter do not change the page; analytics software on the destination reads them to record where a visit came from. You can add them without typing the punctuation by hand using the UTM builder, and what are UTM parameters? explains each one.

Some characters cannot appear literally in a query value. A space, an ampersand or a question mark inside a value would be mistaken for structure, so they are percent-encoded: a space becomes %20, an ampersand %26. URL encoding explained covers the rules.

What is the fragment?

The fragment is everything after the #, and it is handled entirely by the browser. It is never sent to the server.

Its original job is to scroll to a part of the page: #reviews jumps to the element with the ID reviews. Web applications also use it to store state, such as which tab is open.

The fragment comes last, always. If you add query parameters by hand, they must go before the #. Writing https://example.com/page#reviews?utm_source=x puts the tracking tag inside the fragment, where the server will never see it.

How do you read a URL you do not trust?

Find the host first, because the host decides who you are talking to. Three steps:

  1. Skip past https://.
  2. Read up to the first /, ? or #. That is the authority.
  3. If there is an @ in it, discard everything before the @. Then read the remaining labels from right to left to find the registered domain.

Everything after the host, however official it looks, was written by whoever controls that host. A path of /paypal.com/login on an unrelated domain proves nothing.

Short links add a layer, since the host you see is the shortener's and the real destination is hidden behind a redirect. A URL expander follows the redirect for you and shows the final address, so you can apply the same three steps to it before you visit.

Knowing the parts tells you what is safe to remove and what is not. The scheme, host and path usually have to stay. Query parameters are mixed: some select the content, such as a product variant, and some are only tracking. The fragment is optional unless you want to land on a specific section.

When an address is long, the length is nearly always in the query string. That is the part a short link hides, which is why tagged campaign URLs and short links are so often used together.

Frequently asked questions

What are the parts of a URL?
A URL can contain a scheme (https), an authority made of optional user info, a host and an optional port, then a path, an optional query string after a question mark, and an optional fragment after a hash sign.
What is the difference between a domain and a URL?
A domain, such as example.com, identifies a website. A URL is a full address for one resource on it, including the scheme, the domain and usually a path, such as https://example.com/pricing.
What does the question mark in a URL mean?
The question mark starts the query string, a list of name=value pairs separated by ampersands. It passes extra information to the server, such as a search term or tracking tags.
Is the part after the # sent to the server?
No. The fragment after the hash sign stays in the browser. It is used to jump to a section of the page or to hold state for the page's own scripts.
Are URLs case sensitive?
The scheme and host are not: HTTPS://EXAMPLE.COM and https://example.com are the same. The path, query and fragment can be case sensitive, depending on the server.