URLs possess a distinct structure comprising various components, some mandatory and others optional.
The most critical parts are highlighted in the URL below (details follow in subsequent sections).
- Scheme: Indicates the protocol used to access the resource. Besides the common HTTP and HTTPS, numerous other schemes can be used.
- Domain: Specifies the server hosting the resource, which can be a domain name or an IP address.
- Port: Denotes the protocol port for sending the request. It is typically omitted, assuming the default protocol port.
- Path: Defines the path to the resource on the server.
- Parameters: Optional additional information provided to the server.
- Anchor: Represents a specific section within the resource, also known as a fragment.
The combination of the domain name and the port, if included, is referred to as the authority. The scheme and authority are separated by ://. In the absence of an authority, the scheme and the rest of the URL are separated by a colon :. For example, a URL representing an email address, like mailto:[email protected], lacks the authority part.
We have seen uniform resource locator here, and it is used to locate resources on the internet. When we type a URL into a web browser’s address bar, we access a “resource”, not just a webpage.
A URL consists of several components:
- The protocol or scheme, such as
http,https, orftp. - The domain name and port, separated by a period (
.). - The path to the resource, separated by a slash (
/). - Parameters, starting with a question mark (
?), consisting of key-value pairs likea=b&c=d. - The fragment or anchor, indicated by a pound sign (
#), used to bookmark a specific section within the resource.