Understanding URLs
Published
- 1 min read
A URL is a string that identifies a resource on the web, and is the most common type of URI.
URL Structure
The following interactive URL explorer breaks down the components of a URL.
Schemehttps
://
User Infouser:pass
@
Hostapi.example.com
:
Port8080
Path/path/to/resource
?
Queryquery=string
#
Fragmentsection
Components
- Scheme: Defines the protocol (e.g.,
https
,ftp
,mailto
) - User Information: Optional authentication credentials (rarely used today)
- Host: Domain name or IP address
- Port: Optional port number (e.g.,
:443
for HTTPS) - Path: Resource location on the server
- Query String: Optional key-value pairs after
?
- Parameters: Each key-value pair separated by ’&’
- Fragment: Optional anchor or section identifier after
#
- Authority: Combination of user info, host, and port
- Hierarchical Part: Everything between scheme and query
- Resource: Everything after the authority
URL vs URI
- URI (Uniform Resource Identifier): The broader category that includes both URLs and URNs, as defined in RFC 3986
- URL (Uniform Resource Locator): Specifies how to access a resource and where to find it, as defined in RFC 3986
- URN (Uniform Resource Name): Names a resource without specifying how to access it, as defined in RFC 2141
Example:
- URI:
urn:isbn:0-486-27557-4
(identifies a book by ISBN) - URL:
https://example.com/books/123
(locates a specific resource) - URN:
urn:example:book:123
(names a book by its identifier)