Uniform Resource Locator
The Address of the Web
A URL (Uniform Resource Locator) is the address used to access resources on the internet. It's the text you type into your browser's address bar to visit a website or access a specific resource online.
URLs are used to:
A URL consists of several components, each serving a specific purpose:
| Component | Example | Description |
|---|---|---|
| Protocol | https:// |
How to access the resource |
| Domain | www.example.com |
Server address (hostname) |
| Port | :8080 |
Port number (optional, default 80/443) |
| Path | /path/to/page |
Specific resource location |
| Query String | ?key=value |
Parameters (optional) |
| Fragment | #section |
Section within page (optional) |
The protocol defines how to access the resource. It tells the browser which method to use for communication.
http:// - HyperText Transfer Protocol (unsecured)https:// - HTTP Secure (encrypted with SSL/TLS) β Recommendedftp:// - File Transfer Protocolmailto: - Email address linkfile:// - Local file system accesshttps:// when handling sensitive information.
HTTPS encrypts the communication between your browser and the server, protecting data from interception.
The domain name represents the address of the server hosting the resource. It's a human-readable alternative to IP addresses.
www, blog, api, cdn (optional prefix)github, google, amazon (main name).com, .org, .io, .edugithub.com - Main domainapi.github.com - API subdomaindocs.github.com - Documentation subdomainThe path specifies the location of a specific resource on the server. It resembles a file system path.
/)/users/profile - User profile page/products/123 - Product with ID 123/api/v1/data - API endpoint version 1/blog/2024/01/post-title - Blog post with date structureQuery strings pass additional data to the server as key-value pairs. They're commonly used for filtering, searching, and tracking.
?)&)key=value?q=search+term?category=books&price=low?page=2&limit=20?sort=date&order=desc?utm_source=email&utm_campaign=launchFragments point to a specific section within a page. They're processed by the browser, not sent to the server.
#)id attributeSpecial characters in URLs must be encoded to ensure proper transmission. URLs can only contain a limited set of ASCII characters.
URLs can only safely use specific characters from the ASCII set. Characters outside this range,
or characters with special meaning in URLs (like ?, &, =),
must be converted to a percent-encoded format.
| Character | Encoded | Usage |
|---|---|---|
| Space | %20 or + |
Query parameters |
? |
%3F |
Query string delimiter |
& |
%26 |
Parameter separator |
= |
%3D |
Key-value separator |
# |
%23 |
Fragment identifier |
/ |
%2F |
Path separator |
A complete URL including protocol and domain. Can be used from any location.
A path relative to the current location. Used within the same website.
/ - Root of current domain../ - Parent directory (go up one level)./ - Current directory (can be omitted)filename.html - File in current directory-) to separate words, not underscores| Good URL | Bad URL |
|---|---|
/blog/understanding-git |
/page.php?id=12345 |
/products/laptop-dell-xps |
/products?type=laptop&brand=Dell |
/about/team |
/about_us/our_team.html |
Understanding URLs is fundamental to web development and internet usage. A URL is more than just an addressβit's a structured format that communicates how, where, and what resource to access. By following best practices and understanding each component, you can create clean, secure, and user-friendly URLs that enhance both user experience and search engine optimization.