Web Development

URL Explained: Structure, Types, and Best Practices

Define the Uniform Resource Locator (URL) and explore its components, including schemes and paths. Compare URLs vs URIs for better web architecture.

1.0m
url
Monthly Search Volume
Keyword Research

A URL (Uniform Resource Locator) is the address of a unique resource on the internet, specifying both its location on a computer network and the protocol used to retrieve it. Colloquially called a web address, it serves as the primary mechanism browsers use to fetch web pages, images, and other assets. For marketers and SEO practitioners, URL structure directly impacts how search engines classify content and how users perceive trust and relevance.

What is a URL?

A URL is a specific type of Uniform Resource Identifier (URI) that both identifies a resource and specifies the means to access it. While many people use the terms URL and URI interchangeably, a URL implies the access mechanism (such as HTTP or FTP), whereas a URI is the broader category that includes both URLs and Uniform Resource Names (URNs).

The Uniform Resource Locator was defined in RFC 1738 in 1994 by Tim Berners-Lee, the inventor of the World Wide Web, and the URI working group of the Internet Engineering Task Force (IETF) (Wikipedia). The current specification is maintained as a Living Standard by the Web Hypertext Application Technology Working Group (WHATWG) (WHATWG URL Standard).

A URL consists of five hierarchical components organized from left to right:

  1. Scheme: The protocol (e.g., https, ftp)
  2. Authority: The host (domain or IP) and optional port
  3. Path: The resource location on the server
  4. Query: Optional parameters preceded by ?
  5. Fragment: Optional anchor preceded by #

Why URL matters

  • Search classification: Semantic URLs using meaningful words help search engines improve the classification of associated pages (MDN Web Docs).
  • User orientation: Human-readable URLs clarify where users are and what they are interacting with on the web.
  • Security signaling: The scheme indicates whether data transmits securely (HTTPS via TLS) or unencrypted (HTTP).
  • Resource retrieval: URLs enable browsers to locate and display specific resources from servers worldwide.

How URL works

When you type a URL into a browser's address bar or click a link, the browser performs these actions:

  1. Parses the components: The browser breaks the URL into its scheme, authority, path, and other segments according to the URL Standard parsing algorithm.
  2. Resolves the host: The browser converts the domain name to an IP address using the Domain Name System (DNS), or uses the IP address directly if provided in the URL.
  3. Establishes connection: For HTTP or HTTPS, the browser connects to the host on port 80 or 443 by default, or a specified port if included.
  4. Requests the resource: The browser sends an HTTP request for the specified path, including any query parameters.
  5. Processes the response: The server returns the resource, and the browser renders it. If a fragment is present, the browser scrolls to that anchor point after loading.

For Internationalized Resource Identifiers (IRIs) containing Unicode characters, modern browsers automatically convert domain names to punycode (e.g., xn-- format) for DNS compatibility and percent-encode the path using UTF-8.

Types of URLs

Type Definition When to use
Absolute URL Complete address including scheme and domain (e.g., https://example.com/page) Linking from external sites, canonical references, or when context is unknown
Relative URL Partial address resolved against a base URL (e.g., /page or ../page) Internal navigation within the same website to maintain portability across environments
Protocol-relative URL URL without scheme, using // (e.g., //example.com) When resources should load via the current page's protocol (HTTP or HTTPS)
Semantic URL Human-readable address using meaningful words rather than cryptic codes Public-facing content to improve user understanding and search classification

URL vs URI

The terms are often confused. A URL is a specific type of URI.

Aspect URL URI
Scope Specific subset of URIs Broader category including URLs and URNs
Function Locates resource AND specifies access method Identifies resource (may not specify how to retrieve it)
Example http://www.example.com www.example.com (not a URL) or urn:isbn:0451450523

Best practices

  • Prefer HTTPS: Use the HTTPS scheme to ensure data transmits over a secure connection using TLS encryption.
  • Craft semantic paths: Construct URLs with meaningful words that describe the content, making them easier for users to understand and search engines to classify.
  • Avoid credentials in URLs: Do not embed usernames and passwords in URLs (e.g., https://user:[email protected]). This practice is deprecated for security reasons.
  • Limit query parameters: Excessive parameters can create duplicate content issues and confuse crawlers. Use them only when necessary for dynamic content.
  • Handle encoding properly: Ensure non-ASCII characters in paths are UTF-8 percent-encoded to prevent parsing errors.
  • Maintain consistency: Use absolute URLs for external links and canonical tags. Use relative URLs for internal navigation to ease site migrations.

Common mistakes

  • Mistake: Using mixed protocol references (HTTP resources on HTTPS pages). Fix: Use protocol-relative URLs (//) or match the page scheme to prevent mixed content warnings.
  • Mistake: Including fragments for critical content. Fix: Remember that fragments (everything after #) are never sent to the server. They only direct the browser after the page loads. Do not use them for routing logic.
  • Mistake: Creating overly long, parameter-heavy URLs for static content. Fix: Use clean, semantic paths. Dynamic query strings should only control content variation when necessary.
  • Mistake: Ignoring internationalization. Fix: For non-ASCII domains, ensure your system handles punycode conversion. For paths, use percent-encoding to ensure compatibility.
  • Mistake: Relying on backslashes. Fix: URLs use forward slashes (/). Backslashes may work in some Windows contexts but break standard URL parsing.

Examples

Standard web page: https://www.example.com/blog/article?sort=date#comments

File transfer: ftp://files.example.com/downloads/document.pdf

Email composition: mailto:[email protected]?subject=Inquiry&body=Hello

Internationalized domain: http://例子.卷筒纸 converts to http://xn--fsqu00a.xn--3lr804guic/

FAQ

What is the difference between HTTP and HTTPS? HTTP (Hypertext Transfer Protocol) transmits data unencrypted. HTTPS (HTTP Secure) uses SSL/TLS encryption to protect data during transmission, indicated by port 443 instead of port 80.

What is a URL fragment? The fragment, preceded by a hash (#), identifies a secondary resource such as a section heading in an HTML document. Browsers scroll to this element after loading the page. The fragment is not sent to the server with the request.

When should I use absolute vs. relative URLs? Use absolute URLs when linking to external sites or specifying canonical versions. Use relative URLs for internal links within your own site to make the site portable and easier to maintain across staging and production environments.

What is percent-encoding? Percent-encoding converts characters into a format that can be transmitted over the internet using ASCII characters. For example, spaces become %20 and non-ASCII characters are converted to UTF-8 byte sequences prefixed with %.

How do internationalized URLs work? Internationalized URLs (IRIs) contain Unicode characters. Browsers automatically convert the domain to punycode (ASCII-compatible encoding) for DNS lookup, and percent-encode the path using UTF-8.

Why do some URLs have "www" while others do not? The "www" is a subdomain of the domain name. Modern browsers treat example.com and www.example.com as distinct URLs, though they often point to the same content. Choose one version as canonical and redirect the other to avoid duplicate content.

Start Your SEO Research in Seconds

5 free searches/day • No credit card needed • Access all features