ietf-corpus

rfc-1808

Relative Uniform Resource Locators

R. Fielding
date1995-06 streamLegacy statusPROPOSED STANDARD pages16 canonicalhttps://www.rfc-editor.org/rfc/rfc1808 doi10.17487/RFC1808
In situations where the base URL is well-defined and known to the parser (human or machine), it is useful to be able to embed URL references which inherit that context rather than re-specifying it in every instance. This document defines the syntax and semantics for such Relative Uniform Resource Locators. [STANDARDS-TRACK]

obsoleted by

updated by

updates

Extracted elements (22)

design-rationale §3

Base URL precedence is defined in four layers from innermost (highest) to outermost: (1) base URL embedded in document content, (2) base URL of encapsulating entity, (3) URL used to retrieve the entity, (4) empty string (undefined). This layering allows composite documents to override retrieval context without affecting components that define their own base.

http

design-rationale §4

Parameters (';'-delimited) are excluded from relative path resolution because they do not form part of the URL path. In particular, the ';type=d' parameter on an ftp URL must not affect interpretation of relative paths, making parameter-carrying URLs safe base URLs for relative references.

http

design-rationale §1

Relative addressing allows document trees to be partially independent of their location and access scheme. A single set of hypertext documents can be simultaneously accessible via 'file', 'http', and 'ftp' schemes, and trees can be moved as a whole without changing any embedded URLs. Experience in the Web demonstrated this capability is necessary for long-term usability.

http

design-rationale §4

The resolution algorithm in Section 4 is defined as an example against which implementations can be tested; implementation of the algorithm itself is not required. Equivalent implementations (e.g., segment stacks instead of string pattern matches) are acceptable as long as they produce the same output.

http

interoperability-note §5.3

For ftp URLs, the ';type=d' parameter to indicate a directory resource should not be used within contexts that allow relative URLs. If the retrieved directory contains relative URLs, the base URL path must include a trailing slash; using ';type=d' instead of a trailing slash creates ambiguity.

http

interoperability-note §5.3

Path names containing a colon ':' character cannot be used as the first component of a relative URL path (e.g., 'this:that') because parsers will mistake it for a scheme name. Authors must prefix such paths with './' (preferred) or percent-encode the colon as '%3A'.

http

interoperability-note §2.3

RFC 1738 specifies that '?' is allowed in ftp or file path segments and ';' is allowed within http path segments without defined semantics. These are believed to be errors; this document defines ';' within http paths as introducing <params> per the generic-RL syntax, and '?' in ftp/file paths is not supported in practice.

http

interoperability-note §5.2

Some older parsers allow the scheme name to be present in a relative URL if it matches the base URL scheme (e.g., 'http:g' when base is also http). This is considered a loophole in prior specifications and should be avoided; compliant parsers must treat 'http:g' as an absolute URL resolving to '<URL:http:g>', not as a relative path.

http

interoperability-note §2.3

The schemes 'mailto', 'news', and 'telnet' are never appropriate for use with relative URLs. Schemes 'gopher', 'prospero', and 'wais' allow reserved characters outside generic-RL syntax but may be used with relative URLs when the base URL follows generic-RL. Schemes 'file', 'ftp', 'http', and 'nntp' can always be parsed using generic-RL syntax.

http

interoperability-note §5.2

When '..' segments outnumber hierarchical levels in the base path, the excess '..' segments cannot change the <net_loc>; the result retains the original net_loc while the path may include literal '..' components (e.g., '../../../g' from base 'http://a/b/c/d' resolves to 'http://a/../g').

http

normative-requirement §4 MUST

Fragment identifiers are only inherited from the base URL when the entire embedded URL is empty. Parameters do not form part of the URL path and do not affect resolution of relative paths.

http

normative-requirement §3.3 MUST

If retrieval of the base document was the result of a redirected request, the last URL used (i.e., that which resulted in actual retrieval) SHALL be considered the base URL, not the original request URL.

http

normative-requirement §3.4 MUST

It is the responsibility of the distributor(s) of a document containing relative URLs to ensure that the base URL for that document can be established. Relative URLs cannot be used reliably when the document's base URL is not well-defined.

http

normative-requirement §2.3 RECOMMENDED

New URL schemes intended to be used with relative URLs are RECOMMENDED to be designed to be parsable via the generic-RL syntax, and a description of allowed relative forms should be included when a new scheme is registered per RFC 1738 Section 4.

http, registry

normative-requirement §5.2 MUST

Parsers must be capable of consistently resolving abnormal relative URL examples, including cases with more '..' segments than hierarchical levels in the base path and cases where '.' or '..' appear as non-complete path components.

http

normative-requirement §2 MUST

Systems that support relative URLs MUST be able to recognize them as part of the URL parsing process, since a relative URL may appear in any context that could hold an absolute URL.

http

protocol-element §3.1

The Base URL can be embedded in RFC 822-style message headers using the format: 'Base: <URL:absoluteURL>', where 'Base' is case-insensitive and whitespace inside angle brackets is ignored. This header serves as the base for relative URLs in both message headers and enclosed documents.

http, email

protocol-element §2.1

The generic-RL URL syntax consists of six components: <scheme>://<net_loc>/<path>;<params>?<query>#<fragment>. Each component except <scheme> may be absent. The fragment identifier is not considered part of the URL but must be recognized and set aside by parsers.

http

security-consideration §6

There are no security considerations specific to the use or parsing of relative URLs themselves. However, once a relative URL has been resolved to its absolute form, the same security considerations apply as those described in RFC 1738 for absolute URLs.

security, http

state-machine §4

Relative URL resolution is a seven-step algorithm: (1) establish base URL; (2) parse both URLs and check if embedded is empty (inherit base) or has a scheme (treat as absolute); (3) inherit net_loc if embedded net_loc is empty; (4) if embedded path starts with '/', skip to step 7; (5) if embedded path is empty, inherit base path/params/query; (6) merge paths, removing './' and '<segment>/../' patterns iteratively; (7) recombine all components into absolute URL.

http

state-machine §2.4

URL parsing proceeds through six ordered steps: (1) extract fragment after '#', (2) extract scheme before first ':', (3) extract net_loc after '//', (4) extract query after '?', (5) extract params after ';', (6) remainder is the path. Each matched substring including its delimiter is removed from the parse string before the next step.

http

wire-format §2.2

The BNF grammar for relative URLs defines relativeURL as net_path | abs_path | rel_path, where net_path begins with '//', abs_path begins with '/', and rel_path may include optional params (';'-delimited) and query ('?'-delimited). The scheme is 1*(alpha | digit | '+' | '-' | '.') and escape sequences use '%' hex hex encoding.

http