Network Working Group R. Fielding Request for Comments: 1808 UC Irvine Category: Standards Track June 1995 Relative Uniform Resource Locators
Status of this Memo
This document specifies an Internet standards track protocol for the Internet community, and requests discussion and suggestions for
improvements. Plea refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited. Abstract
A Uniform Resource Locator (URL) is a compact reprentation of the
location and access method for a resource available via the Internet. When embedded within a ba document, a URL in its absolute form may contain a great deal of information which is already known from the
context of that ba document’s retrieval, including the scheme,
network location, and parts of the url-path. In situations where the ba URL is well-defined and known to the parr (human or machine), it is uful 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 mantics for such Relative Uniform
Resource Locators.
1. Introduction
This document describes the syntax and mantics for "relative"
Uniform Resource Locators (relative URLs): a compact reprentation
of the location of a resource relative to an absolute ba URL. It
is a companion to RFC 1738, "Uniform Resource Locators (URL)" [2],
which specifies the syntax and mantics of absolute URLs.
A common u for Uniform Resource Locators is to embed them within a document (referred to as the "ba" document) for the purpo of
identifying other Internet-accessible resources. For example, in
hypertext documents, URLs can be ud as the identifiers for
hypertext link destinations.
Absolute URLs contain a great deal of information which may already
be known from the context of the ba document’s retrieval, including the scheme, network location, and parts of the URL path. In
situations where the ba URL is well-defined and known, it is uful to be able to embed a URL reference which inherits that context Fielding Standards Track [Page 1]德国人口数
rather than re-specifying it within each instance. Relative URLs can also be ud within data-entry dialogs to decrea the number of
康荣臻
characters necessary to describe a location.
In addition, it is often the ca that a group or "tree" of documents has been constructed to rve a common purpo; the vast majority of URLs in the documents point to locations within the tree rather
than outside of it. Similarly, documents located at a particular
Internet site are much more likely to refer to other resources at
that site than to resources at remote sites.
Relative addressing of URLs allows document trees to be partially
independent of their location and access scheme. For instance, it is possible for a single t of hypertext documents to be simultaneously accessible and traversable via each of the "file", "http", and "ftp" schemes if the documents refer to each other using relative URLs.
Furthermore, document trees can be moved, as a whole, without
changing any of the embedded URLs. Experience within the World-Wide Web has demonstrated that the ability to perform relative referencing is necessary for the long-term usability of embedded URLs.
2. Relative URL Syntax
The syntax for relative URLs is a shortened form of that for absolute URLs [2], where some prefix of the URL is missing and certain path
components ("." and "..") have a special meaning when interpreting a relative path. Becau a relative URL may appear in any context that could hold an absolute URL, systems that support relative URLs must
be able to recognize them as part of the URL parsing process.
Although this document does not ek to define the overall URL
海洋权益
syntax, some discussion of it is necessary in order to describe the
parsing of relative URLs. In particular, ba documents can only
make u of relative URLs when their ba URL fits within the
喜出望外意思generic-RL syntax described below. Although some URL schemes do not require this generic-RL syntax, it is assumed that any document which contains a relative reference does have a ba URL that obeys the汽修毕业论文
syntax. In other words, relative URLs cannot be ud within
documents that have unsuitable ba URLs.
2.1. URL Syntactic Components
The URL syntax is dependent upon the scheme. Some schemes u
rerved characters like "?" and ";" to indicate special components, while others just consider them to be part of the path. However,
there is enough uniformity in the u of URLs to allow a parr to
resolve relative URLs bad upon a single, generic-RL syntax. This
generic-RL syntax consists of six components:
Fielding Standards Track [Page 2]
<scheme>://<net_loc>/<path>;<params>?<query>#<fragment>
each of which, except <scheme>, may be abnt from a particular URL. The components are defined as follows (a complete BNF is provided
in Section 2.2):
scheme ":" ::= scheme name, as per Section 2.1 of RFC 1738 [2]. "//" net_loc ::= network location and login information, as per
Section 3.1 of RFC 1738 [2].
"/" path ::= URL path, as per Section 3.1 of RFC 1738 [2].
";" params ::= object parameters (e.g., ";type=a" as in
Section 3.2.2 of RFC 1738 [2]).
"?" query ::= query information, as per Section 3.3 of
RFC 1738 [2].
"#" fragment ::= fragment identifier.
Note that the fragment identifier (and the "#" that precedes it) is
not considered part of the URL. However, since it is commonly ud
within the same string context as a URL, a parr must be able to
recognize the fragment when it is prent and t it aside as part of the parsing process.
The order of the components is important. If both <params> and
<query> are prent, the <query> information must occur after the
<params>.
2.2. BNF for Relative URLs
This is a BNF-like description of the Relative Uniform Resource
Locator syntax, using the conventions of RFC 822 [5], except that "|" is ud to designate alternatives. Briefly, literals are quoted with "", parenthes "(" and ")" are ud to group elements, optional
elements are enclod in [brackets], and elements may be preceded怀孕初期吃什么好
with <n>* to designate n or more repetitions of the following
element; n defaults to 0.
This BNF also describes the generic-RL syntax for valid ba URLs.
Note that this differs from the URL syntax defined in RFC 1738 [2] in that all schemes are required to u a single t of rerved
characters and u them consistently within the major URL components. Fielding Standards Track [Page 3]
URL = ( absoluteURL | relativeURL ) [ "#" fragment ]
absoluteURL = generic-RL | ( scheme ":" *( uchar | rerved ) )
generic-RL = scheme ":" relativeURL
relativeURL = net_path | abs_path | rel_path
net_path = "//" net_loc [ abs_path ]
abs_path = "/" rel_path
rel_path = [ path ] [ ";" params ] [ "?" query ]
path = fgment *( "/" gment )
fgment = 1*pchar
gment = *pchar
params = param *( ";" param )
param = *( pchar | "/" )
scheme = 1*( alpha | digit | "+" | "-" | "." )
net_loc = *( pchar | ";" | "?" )
query = *( uchar | rerved )
fragment = *( uchar | rerved )
pchar = uchar | ":" | "@" | "&" | "="
uchar = unrerved | escape
unrerved = alpha | digit | safe | extra
escape = "%" hex hex
hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
"a" | "b" | "c" | "d" | "e" | "f"
alpha = lowalpha | hialpha
lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
"j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
"s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
hialpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
"J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
"S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
"8" | "9"
safe = "$" | "-" | "_" | "." | "+"
extra = "!" | "*" | "’" | "(" | ")" | ","
national = "{" | "}" | "|" | "\" | "^" | "˜" | "[" | "]" | "‘"
rerved = ";" | "/" | "?" | ":" | "@" | "&" | "="
punctuation = "<" | ">" | "#" | "%" | <">
Fielding Standards Track [Page 4]
2.3. Specific Schemes and their Syntactic Categories
Each URL scheme has its own rules regarding the prence or abnce
of the syntactic components described in Sections 2.1 and 2.2. In
addition, some schemes are never appropriate for u with relative
URLs. However, since relative URLs will only be ud within contexts in which they are uful, the scheme-specific differences can be
ignored by the resolution process.
Within this ction, we include as examples only tho schemes that
have a defined URL syntax in RFC 1738 [2]. The following schemes are never ud with relative URLs:
mailto Electronic Mail
青少年xxxnews USENET news
telnet TELNET Protocol for Interactive Sessions
Some URL schemes allow the u of rerved characters for purpos
outside the generic-RL syntax given above. However, such u is
rare. Relative URLs can be ud with the schemes whenever the
applicable ba URL follows the generic-RL syntax.
gopher Gopher and Gopher+ Protocols
prospero Prospero Directory Service
wais Wide Area Information Servers Protocol白夜行解析
Urs of gopher URLs should note that gopher-type information is
almost always included at the beginning of what would be the
generic-RL path. If prent, this type information prevents
relative-path references to documents with differing gopher-types.
Finally, the following schemes can always be pard using the
generic-RL syntax. This does not necessarily imply that relative
URLs will be uful with the schemes -- that decision is left to
the system implementation and the author of the ba document.
file Host-specific Files
ftp File Transfer Protocol
http Hypertext Transfer Protocol
nntp USENET news using NNTP access
NOTE: Section 5 of RFC 1738 specifies that the question-mark
character ("?") is allowed in an ftp or file path gment.
However, this is not true in practice and is believed to be an error in the RFC. Similarly, RFC 1738 allows the rerved
character micolon (";") within an http path gment, but does not define its mantics; the correct mantics are as defined by this document for <params>.
Fielding Standards Track [Page 5]