URL anatomy
This course breaks a URL into its parts and explains what each one does. It starts with the difference between URL, URI and URN, then covers the scheme, host and domain, port, path, query string and fragment. It explains percent encoding for reserved and non-ASCII characters, and why secrets in query strings can leak. The last lesson shows how Rails works with URLs through the router, _path and _url helpers, the request object and slugs.
What you'll learn
- ✓The components of a URL and how URL, URI and URN differ
- ✓How schemes select protocols such as HTTP, HTTPS and WebSocket
- ✓Domain structure, subdomains, DNS resolution and localhost
- ✓Ports, path segments and RESTful path conventions
- ✓Query strings, fragments and percent encoding
- ✓Rails routes, _path and _url helpers, and the request object
What is a URL?
Every time you click a link, type an address in your browser, or submit a form: you're using a URL. It's so common that most people never think about what it is.
Read the full lesson free →Curriculum
7 lessonsWhat is a URL?
Defines a URL, separates it from URI and URN, and names its components and absolute versus relative forms.
Scheme and protocol
Explains how the scheme selects a protocol, compares HTTP and HTTPS, and covers other schemes and Rails helpers.
Host and domain
Covers host formats, domain hierarchy with TLDs and subdomains, DNS resolution, localhost and host methods in Rails.
Port and path
Describes ports, default ports and port ranges, then path segments, RESTful conventions and Rails route mapping.
Query string and fragment
Shows query string structure, why fragments never reach the server, the risk of secrets in URLs, and Rails params.
URL encoding and special characters
Explains reserved and unreserved characters, percent encoding, UTF-8 encoding of Unicode, and how Rails encodes and decodes.
URLs in Rails development
Covers the Rails router, _path and _url helpers, the request object, query and anchor options, and slugs.