Uniform Resource Locator (URL)
Written by: Editorial Team
What is a Uniform Resource Locator (URL)? A Uniform Resource Locator (URL) is a specific string of characters used to identify and access resources on the internet. It acts as the address for web pages, files, images, videos, and other content that can be accessed via a web brows
What is a Uniform Resource Locator (URL)?
A Uniform Resource Locator (URL) is a specific string of characters used to identify and access resources on the internet. It acts as the address for web pages, files, images, videos, and other content that can be accessed via a web browser or other online tools. A URL tells the user and the system where to find the resource and how to retrieve it.
Structure of a URL
A URL is composed of different parts that work together to locate and retrieve a resource. Understanding these parts is key to knowing how URLs function. Below is the general structure of a URL:
scheme://domain:port/path?query#fragment
Each part plays a specific role, which we'll discuss below.
1. Scheme (Protocol)
The scheme specifies the protocol or method that should be used to access the resource. The most common schemes are:
- HTTP (Hypertext Transfer Protocol): Used for most websites.
- HTTPS (HTTP Secure): The secure version of HTTP, used for encrypted communication over the internet.
- FTP (File Transfer Protocol): Used for transferring files.
- Mailto: Used to open email clients and send emails.
The scheme is always followed by ://. For example, in https://www.example.com, "https" is the scheme, indicating that the website is using a secure connection.
2. Domain (Hostname)
The domain, also known as the hostname, identifies the server where the resource is hosted. This is typically the name of the website or service, and it is divided into subdomains, the domain name itself, and the top-level domain (TLD).
For example, in the URL https://www.example.com:
- www: This is the subdomain, which can be optional. Websites can have various subdomains like "blog", "store", or "mail".
- example: This is the domain name, the core identity of the website.
- .com: This is the top-level domain (TLD). Common TLDs include
.com,.org,.net,.edu, and country-specific ones like.uk(United Kingdom) or.ca(Canada).
The domain is crucial because it points to the specific server where the resource is hosted. Without it, the web browser wouldn’t know where to look.
3. Port
The port is an optional part of the URL that specifies the port number to use when connecting to the server. Most of the time, this part is hidden because web browsers automatically assume certain ports based on the scheme. For example:
- Port 80 is assumed for HTTP.
- Port 443 is assumed for HTTPS.
However, custom applications or services may specify a different port. In that case, it would appear right after the domain name, separated by a colon (:). For example: https://www.example.com:8080. Here, 8080 is the port number.
4. Path
The path follows the domain and specifies the exact location of the resource within the server. If you think of the domain as the address of a house, the path is like the room or section within that house.
For example, in the URL https://www.example.com/blog/article, the path is /blog/article. It tells the server that the user wants to access the "article" page under the "blog" directory. Paths can represent directories and files, and they are typically structured in a hierarchical way.
5. Query String
The query string is used to pass additional parameters to the server, often as key-value pairs. It begins with a question mark (?) and is followed by parameters separated by ampersands (&). Query strings are often used in dynamic websites to filter results, search for specific items, or pass user data.
For example, in the URL https://www.example.com/search?q=URL&sort=asc, the query string is ?q=URL&sort=asc. Here, q=URL might represent a search query for "URL", and sort=asc could instruct the server to sort results in ascending order.
6. Fragment (Anchor)
The fragment, also known as an anchor, is an optional part of the URL that points to a specific section within a web page. It begins with a hashtag (#) and usually represents an identifier for a specific part of the document.
For example, in the URL https://www.example.com/page#section1, the fragment is #section1. This tells the browser to navigate directly to the part of the page labeled as "section1".
Fragments are especially useful for long web pages where users may want to jump directly to a particular section without scrolling.
How URLs Work
When you enter a URL into your web browser, a series of steps occur in the background to retrieve the resource you requested:
- DNS Resolution: The domain name (e.g.,
www.example.com) is translated into an IP address through the Domain Name System (DNS). The IP address represents the physical location of the server hosting the website. - Establishing a Connection: The browser establishes a connection with the server using the specified protocol (e.g., HTTP or HTTPS). If a secure connection is required (in the case of HTTPS), the browser will also handle encryption through an SSL/TLS handshake.
- Making a Request: Once the connection is established, the browser sends a request to the server for the resource. The request might include the path, query string, and other details.
- Receiving the Response: The server processes the request and sends back the requested resource, which might be a web page, file, image, etc.
- Rendering the Content: The browser then renders the content, displaying the web page or file according to its type.
Common Types of URLs
URLs can vary depending on their function or the type of resource they refer to. Some common types include:
- Absolute URLs: These URLs contain the full path, including the scheme, domain, and everything necessary to locate the resource. For example,
https://www.example.com/page.htmlis an absolute URL. - Relative URLs: These URLs are incomplete and rely on the current context (usually the domain and path) to locate a resource. For example,
/images/photo.jpgis a relative URL, which assumes the base domain is already known. - Data URLs: These URLs embed data directly into the URL itself. They are often used for small images or files. For example:
data:image/png;base64,iVBORw.... - Mailto URLs: Used to initiate email composition through an email client. For example,
mailto:someone@example.comopens the user’s email client to send an email.
URL vs URI vs URN
URLs are a subset of Uniform Resource Identifiers (URI), which is a broader term encompassing any string that identifies a resource, either by its location or by its name.
- A URI can be a URL (which provides a location) or a Uniform Resource Name (URN), which identifies a resource by name but doesn’t necessarily provide its location. For instance,
urn:isbn:978-3-16-148410-0is a URN for a book.
URLs focus specifically on the location of resources, whereas URIs can be used to describe both names and locations.
The Bottom Line
A Uniform Resource Locator (URL) is the specific address used to access resources on the internet. It consists of several parts, including the scheme, domain, path, query string, and fragment. URLs are essential for navigating the web and retrieving information from servers. Understanding how URLs work is fundamental to internet use, whether for browsing, managing websites, or accessing various online services. URLs are a critical part of web technology, making it possible to share, retrieve, and interact with content across the internet.