Host, Path, and Query in a URL

A URL includes components serving different roles. For an HTTP URL, the host helps select the service and the path and query identify the requested target in that service.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Read a simple target
  2. Keep client fragments separate
  3. Trace which component changes the selected resource or view
  4. Keep escaping and URL structure separate

Read a simple target

In https://example.org/books?q=algebra, the host is example.org, the path is /books, and the query has q=algebra. Hostnames and addresses distinguish a service label from the selected network address.

Keep client fragments separate

A fragment can identify a location within a representation in the client. It is not part of the ordinary HTTP request target. Reading a request provides the fields the server observes.[1][2]

Trace which component changes the selected resource or view

For https://catalog.example/items/7?view=brief#details, the hostname is catalog.example, the path is /items/7, and the query supplies a brief view parameter. The fragment is interpreted by the client and is not part of the HTTP request target. See a request's parts.

Scheme: https
Host: catalog.example
Path: /items/7
Query: view=brief
Client-side fragment: details

Keep escaping and URL structure separate

A delimiter encoded inside a parameter value need not start another URL component. Build and parse URLs with a library that knows the format. Test repeated query names and values containing characters with special meaning.

References

  1. Larry Peterson and Bruce Davie, Computer Networks: A Systems Approach ↩
  2. IETF, RFC 9110: HTTP Semantics ↩