uri

Section: Environments, Tables, and Troff Macros (7)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

uri, url, urn - uniform resource identifier (URI) (URL と URN も含めて)  

書式

[~absoluteURI | relativeURI~] [~"#"~fragment~]

scheme~.RB " : " (~hierarchical_part | opaque_part~)

(~net_path | absolute_path | relative_path~) [~"?"~query~]

"http" | "ftp" | "gopher" | "mailto" | "news" | "telnet" | "file" | "ftp" | "man" | "info" | "whatis" | "ldap" | "wais" | ...

(~net_path | absolute_path~) [~"?"~query~]

"//"~authority [~absolute_path~]

"/"~path_segments

relative_segment [~absolute_path~]  

説明

Uniform Resource Identifier (URI) は抽象的・物理的なリソース (web ページなど) を識別するための短い文字列である。 Uniform Resource Locator (URL) は URI の一種で、 リソースの名前などの属性でではなく、 そのリソースに対応するアクセスメカニズムを通してリソースを指定する (つまりネットワーク上の「場所 (location)」を指定する)。 Uniform Resource Name (URN) は URI の一種で、 これは対象のリソースが廃棄されたり利用できなくなった場合にも、 グローバルに他と重なることなく永続しなければならない。

URI は、 web ブラウザなどのツールで ハイパーテキストリンクのリンク先を指定する時の標準的な方法である。 文字列 "http://www.kernel.org" は URL である (従って URI でもある)。多くの人々は、 URL という言葉をほぼ URI の 同義語として使っている (しかし技術的には URL は URI のサブセットである)。

URI は絶対的にも相対的にも指定できる。 絶対的な指定は、リソースをコンテクストに依存しないかたちで参照する。 相対的な指定は、リソースを現在のコンテクストからの差異によって記述する。 相対パス参照では、 "." および ".." だけのパス部分 (path segment) は特別な意味を持ち、 それぞれ「現在の階層レベル」および「現在の階層の一つ上のレベル」 として扱われる (UNIX 風のシステムと同様)。 コロン文字を含むパス部分は相対 URI パスの先頭に用いることはできない (つまり "this:that" はダメ)。スキーム名と区別できないからである。 このような場合には ./ を前置すること (つまり "./this:that" とする)。 MS-DOS の子孫 (Microsoft Windows など) は、 デバイス名のコロンを URI では垂直バー ("|") に置き換える。 したがって "C:" は "C|" となる。

A fragment identifier, if included, refers to a particular named portion (fragment) of a resource; text after a '#' identifies the fragment. A URI beginning with '#' refers to that fragment in the current resource.  

使い方

URI のスキームには色々な種類があり、 それぞれ固有のルールや意味が追加されている。 しかしできるだけ統一したものにしようという努力もなされている。 例えば、多くの URL スキームは「機関 (authority)」に対して以下の書式 (ここでは ip_server と呼ぶことにする) を許している (角括弧内部は省略可能)。

ip_server = [user [ : password ] @ ] host [ : port]

このフォーマットには、ユーザー名、ユーザー名+パスワードを指定できる。 ポート番号を追加することも可能である。 host はホストコンピュータの名前で、 DNS で定義される名前か IP アドレス (ピリオドで区切られた数字) で指定する。したがって URI <http://fred:fredpassword@example.com:8080/> は、ホスト example.com に fred として (パスワードを使って) ポート 8080 を使ってログインする。 パスワードは可能なら URI には含めないほうが良いだろう。 パスワードを直書きすると様々なセキュリティ上のリスクが生じるからである。 URL にユーザー名だけを与え、パスワードを与えない場合は、 リモートサーバはパスワードを要求してくる。 URL を解釈したプログラムが、ユーザーにこの入力を促すことになろう。

以下に、 UNIX 風のシステムで非常に良く用いられており、 多くのツールが理解するスキームを示す。 URI を使うツールの多くでは、内部スキームや特殊なスキームも 使えることが多い。そのようなスキームに関してはツールのドキュメントを見ること。

http - Web (HTTP) サーバ

http://ip_server/path
http://ip_server/path?query

This is a URL accessing a web (HTTP) server. The default port is 80. If the path refers to a directory, the web server will choose what to return; usually if there is a file named "index.html" or "index.htm", its content is returned; otherwise, a list of the files in the current directory (with appropriate links) is generated and returned. An example is <http://lwn.net>.

A query can be given in the archaic "isindex" format, consisting of a word or phrase and not including an equal sign (=). A query can also be in the longer "GET" format, which has one or more query entries of the form key=value separated by the ampersand character (&). Note that key can be repeated more than once, though it's up to the web server and its application programs to determine if there's any meaning to that. There is an unfortunate interaction with HTML/XML/SGML and the GET query format; when such URIs with more than one key are embedded in SGML/XML documents (including HTML), the ampersand (&) has to be rewritten as &amp;. Note that not all queries use this format; larger forms may be too long to store as a URI, so they use a different interaction mechanism (called POST) which does not include the data in the URI. See the Common Gateway Interface specification at http://www.w3.org/CGI for more information.

ftp - ファイル転送プロトコル (FTP)

ftp://ip_server/path

これはファイル転送プロトコル (FTP) を通してファイルにアクセスするための URL である。デフォルトの (制御用) ポートは 21 である。 ユーザー名がない場合には、ユーザー名 anonymous が与えられる。 そしてその場合には、クライアントの多くは要求した人の インターネットメールアドレスをパスワードとして与える。 例としては <ftp://ftp.is.co.za/rfc/rfc1808.txt> など。

gofer - Gofer サーバ

gopher://ip_server/gophertype selector
gopher://ip_server/gophertype selector%09search
gopher://ip_server/gophertype selector%09search%09gopher+_string

The default gopher port is 70. gophertype is a single-character field to denote the Gopher type of the resource to which the URL refers. The entire path may also be empty, in which case the delimiting "/" is also optional, and the gophertype defaults to "1".

selector は Gopher セレクタ文字列である。Gopher プロトコルでは、 Gopher セレクタ文字列はオクテット文字からなり、 16進数の 09 (US-ASCII の HT または tab)、 0A (US-ASCII の LF 文字)、 0D (US-ASCII の CR 文字) 以外ならどんなオクテットも指定できる。

mailto - 電子メールアドレス

mailto:email-address

これは電子メールアドレスで、通常 name@hostname という形式をとる。電子メールアドレスの正しいフォーマットに関する より詳しい情報は mailaddr(7) を見よ。 % 文字はすべて %25 と書き直さなければならないことに注意。 例としては <mailto:dwheeler@dwheeler.com> など。

news - ニュースグループ、ニュースメッセージ

news:newsgroup-name
news:message-id

newsgroup-name はピリオドで区切られた階層的な名前である。例えば "comp.infosystems.www.misc" など。 <newsgroup-name> が "*" (つまり <news:*>) の場合には、 「参照できる全てのニュースグループ」の意味になる。 例としては <news:comp.lang.ada> など。

A message-id corresponds to the Message-ID of IETF RFC 1036, without the enclosing "<" and ">"; it takes the form unique@full_domain_name. A message identifier may be distinguished from a news group name by the presence of the "@" character.

telnet - telnet ログイン

telnet://ip_server/

Telnet URL スキームは対話的なテキストサービスに Telnet プロトコルを 通してアクセスするために用いられる。最後の "/" 文字は省略してよい。 例としては <telnet://melvyl.ucop.edu/> など。

file - 通常のファイル

file://ip_server/path_segments
file:path_segments

これはローカルに直接アクセスできるファイルを示す。 特殊なケースとして、 ip_server には "localhost" という文字列を用いたり、空文字にしてもよい。 これは「URI が解釈されたマシン」とみなされる。 path がディレクトリの場合は、ビューアはディレクトリの内容を リンクを張ったかたちで表示するとよいだろう。 しかし現在は、まだ全てのビューアがこの動作をするわけではない。 KDE は生成ファイル (generated file) を URL <file:/cgi-bin> の形式でサポートしている。 与えられたファイルが見付からなかった場合は、 ファイル名をグロブによって展開すると良いかもしれない (glob(7) および glob(3) を見よ)。

The second format (e.g., <file:/etc/passwd>) is a correct format for referring to a local file. However, older standards did not permit this format, and some programs don't recognize this as a URI. A more portable syntax is to use an empty string as the server name, for example, <file:///etc/passwd>; this form does the same thing and is easily recognized by pattern matchers and older programs as a URI. Note that if you really mean to say "start from the current location", don't specify the scheme at all; use a relative address like <../test.txt>, which has the side-effect of being scheme-independent. An example of this scheme is <file:///etc/passwd>.

man - man ページ文書

man:command-name
man:command-name(section)

これはローカルのオンラインマニュアル (man) リファレスページを参照する。 command-name には括弧とセクション番号を追加してもよい。 セクション番号の意味について詳しく知りたい場合は man(7) をみよ。この URI スキームは UNIX 風のシステム (Linux など) に特有のものであり、現在はまだ IETF による登録はされていない。 例としては <man:ls(1)> など。

info - info ページ文書

info:virtual-filename
info:virtual-filename#nodename
info:(virtual-filename)
info:(virtual-filename)nodename

This scheme refers to online info reference pages (generated from texinfo files), a documentation format used by programs such as the GNU tools. This URI scheme is unique to UNIX-like systems (such as Linux) and is not currently registered by the IETF. As of this writing, GNOME and KDE differ in their URI syntax and do not accept the other's syntax. The first two formats are the GNOME format; in nodenames, all spaces are written as underscores. The second two formats are the KDE format; spaces in nodenames must be written as spaces, even though this is forbidden by the URI standards. It's hoped that in the future most tools will understand all of these formats and will always accept underscores for spaces in nodenames. In both GNOME and KDE, if the form without the nodename is used, the nodename is assumed to be "Top". Examples of the GNOME format are <info:gcc> and <info:gcc#G++_and_GCC>. Examples of the KDE format are <info:(gcc)> and <info:(gcc)G++ and GCC>.

whatis - 文書検索

whatis:string

このスキームは、コマンドに関する短い (1 行の) 説明を集めた データベースを検索し、 string を含む文字列をリストして返す。 単語が完全にマッチした結果だけが返される。 whatis(1) を見よ。 この URI スキームは UNIX 風のシステム (Linux など) に特有のものであり、現在はまだ IETF による登録はされていない。

ghelp - GNOME ヘルプ文書

ghelp:name-of-application

与えられた application に対応する GNOME help をロードする。 この書式を用いた文書はまだあまり多くない。

ldap - 軽量ディレクトリアクセスプロトコル

ldap://hostport
ldap://hostport/
ldap://hostport/dn
ldap://hostport/dn?attributes
ldap://hostport/dn?attributes?scope
ldap://hostport/dn?attributes?scope?filter
ldap://hostport/dn?attributes?scope?filter?extensions

This scheme supports queries to the Lightweight Directory Access Protocol (LDAP), a protocol for querying a set of servers for hierarchically organized information (such as people and computing resources). See RFC 2255 for more information on the LDAP URL scheme. The components of this URL are:

hostport
クエリーを行う LDAP サーバ。ホスト名を書く。続けてコロンとポート番号を 追加することもできる。 LDAP のデフォルトのポートは TCP ポート 389 である。 省略されると、どの LDAP サーバを用いるかはクライアントが決定する。
dn
the LDAP Distinguished Name, which identifies the base object of the LDAP search (see RFC 2253 section 3).
attributes
コンマ区切りの、返される属性 (attribute) のリスト。 RFC 2251 の section 4.1.5 を見よ。省略されると全ての属性が返される。
scope
検索のスコープを指定する。 "base" (base オブジェクト検索), "one" (1 レベル検索), "sub" (サブツリー検索) のいずれかを指定する。 省略すると "base" が仮定される。
filter
specifies the search filter (subset of entries to return). If omitted, all entries should be returned. See RFC 2254 section 4.
extensions
a comma-separated list of type=value pairs, where the =value portion may be omitted for options not requiring it. An extension prefixed with a '!' is critical (must be supported to be valid), otherwise it is noncritical (optional).

LDAP のクエリーは、例とともに説明するのが最も簡単である。 次の例は、 ldap.itd.umich.edu に、 U.S. にある University of Michigan の情報を尋ねる例である。

ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US

郵便用の住所属性だけを取得する場合は、 次のようにリクエストする:

ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress

host.com のポート 6666 に、 University of Michigan にいる common name (cn) が "Babs Jenson" の人の情報を尋ねる場合は、 次のようにリクエストする:

ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)

wais - 広域情報サービス

wais://hostport/database
wais://hostport/database?search
wais://hostport/database/wtype/wpath

This scheme designates a WAIS database, search, or document (see IETF RFC 1625 for more information on WAIS). Hostport is the hostname, optionally followed by a colon and port number (the default port number is 210).

The first form designates a WAIS database for searching. The second form designates a particular search of the WAIS database database. The third form designates a particular document within a WAIS database to be retrieved. wtype is the WAIS designation of the type of the object, and wpath is the WAIS document-id.

その他のスキーム

There are many other URI schemes. Most tools that accept URIs support a set of internal URIs (e.g., Mozilla has the about: scheme for internal information, and the GNOME help browser has the toc: scheme for various starting locations). There are many schemes that have been defined but are not as widely used at the current time (e.g., prospero). The nntp: scheme is deprecated in favor of the news: scheme. URNs are to be supported by the urn: scheme, with a hierarchical name space (e.g., urn:ietf:... would identify IETF documents); at this time, URNs are not widely implemented. Not all tools support all schemes.  

文字エンコード

URI では、色々な状況下で入力できるように、文字の種類を制限している。

以下の文字は予約されている。すなわち、これらの文字は URI に登場することがあるが、それらの利用法 (解釈のされ方) は 予約された目的に制限されている (衝突するデータは URI にする前にエスケープしなければならない)。

; / ? : @ & = + $ ,

Unreserved characters may be included in a URI. Unreserved characters include uppercase and lowercase Latin letters, decimal digits, and the following limited set of punctuation marks and symbols:

- _ . ! ~ * ' ( )

All other characters must be escaped. An escaped octet is encoded as a character triplet, consisting of the percent character "%" followed by the two hexadecimal digits representing the octet code (you can use uppercase or lowercase letters for the hexadecimal digits). For example, a blank space must be escaped as "%20", a tab character as "%09", and the "&" as "%26". Because the percent "%" character always has the reserved purpose of being the escape indicator, it must be escaped as "%25". It is common practice to escape space characters as the plus symbol (+) in query text; this practice isn't uniformly defined in the relevant RFCs (which recommend %20 instead) but any tool accepting URIs with query text should be prepared for them. A URI is always shown in its "escaped" form.

Unreserved characters can be escaped without changing the semantics of the URI, but this should not be done unless the URI is being used in a context that does not allow the unescaped character to appear. For example, "%7e" is sometimes used instead of "~" in an HTTP URL path, but the two are equivalent for an HTTP URL.

For URIs which must handle characters outside the US ASCII character set, the HTML 4.01 specification (section B.2) and IETF RFC~3986 (last paragraph of section 2.5) recommend the following approach:

(1)
translate the character sequences into UTF-8 (IETF RFC~3629) ---see utf-8(7)--- and then
(2)
URI エスケープ機構を用いる。 つまり、安全でないオクテットを %HH でエンコードする。
 

URI を書くには

When written, URIs should be placed inside double quotes (e.g., "http://www.kernel.org"), enclosed in angle brackets (e.g., <http://lwn.net>), or placed on a line by themselves. A warning for those who use double-quotes: never move extraneous punctuation (such as the period ending a sentence or the comma in a list) inside a URI, since this will change the value of the URI. Instead, use angle brackets instead, or switch to a quoting system that never includes extraneous characters inside quotation marks. This latter system, called the 'new' or 'logical' quoting system by "Hart's Rules" and the "Oxford Dictionary for Writers and Editors", is preferred practice in Great Britain and in various European languages. Older documents suggested inserting the prefix "URL:" just before the URI, but this form has never caught on.

The URI syntax was designed to be unambiguous. However, as URIs have become commonplace, traditional media (television, radio, newspapers, billboards, etc.) have increasingly used abbreviated URI references consisting of only the authority and path portions of the identified resource (e.g., <www.w3.org/Addressing>). Such references are primarily intended for human interpretation rather than machine, with the assumption that context-based heuristics are sufficient to complete the URI (e.g., hostnames beginning with "www" are likely to have a URI prefix of "http://" and hostnames beginning with "ftp" likely to have a prefix of "ftp://"). Many client implementations heuristically resolve these references. Such heuristics may change over time, particularly when new schemes are introduced. Since an abbreviated URI has the same syntax as a relative URL path, abbreviated URI references cannot be used where relative URIs are permitted, and can be used only when there is no defined base (such as in dialog boxes). Don't use abbreviated URIs as hypertext links inside a document; use the standard format as described here.  

標準規格

(IETF RFC 2396) , (HTML 4.0) .  

注意

Any tool accepting URIs (e.g., a web browser) on a Linux system should be able to handle (directly or indirectly) all of the schemes described here, including the man: and info: schemes. Handling them by invoking some other program is fine and in fact encouraged.

Technically, the fragment isn't part of the URI.

For information on how to embed URIs (including URLs) in a data format, see documentation on that format. HTML uses the format <A HREF="uri"> text </A>. Texinfo files use the format @uref{uri}. Man and mdoc have the recently added UR macro, or just include the URI in the text (viewers should be able to detect :// as part of a URI).

デスクトップ環境である GNOME と KDE は、 それぞれ受付ける URI が (特にそれぞれのヘルプブラウザにおいて) 異なっている。 man ページをリストするには、 GNOME では <toc:man> を用い、 KDE では <man:(index)> を用いる。 また info ページをリストするには、 GNOME では <toc:info> を用い、 KDE では <info:(dir)> を用いる (本 man ページの著者は KDE のアプローチのほうが好みである。 しかしより標準的な書式の方が更に良いが)。 一般に KDE は生成ファイル (generated file) のプレフィックスとして <file:/cgi-bin/> を用いる。 KDE は HTML の文書を <file:/cgi-bin/helpindex> 経由でアクセスするのが好みなようである。 GNOME は文書の保管・検索に ghelp スキームを用いる方法を取っているようだ。 どちらのブラウザも、現時点では file: によるディレクトリ参照を扱えない。 したがってディレクトリ全体をブラウズ可能な URI で参照することが難しい。 先に述べたように、これら二つの環境では info: スキームの 扱いが異なっている (おそらく最も重要な差異であろう)。 GNOME と KDE が共通 URI フォーマットに収斂することが望ましい。 この man ページが、将来はその収斂した結果を記述できることを望む。 この作業への助力を喚起したい。  

セキュリティ

URI そのものはセキュリティの脅威を引き起こすものではない。 ある時点ではリソースの場所を与えていた URL が、 ずっとそうでありつづけるという保証は一般にはない。 またある URL が、将来には別のリソースを示さないとも限らない。 このような保証は、その名前空間とリソースとを管理している個人に 帰するものに過ぎない。

無害に見える操作 (リソースに関連づけられたエンティティの取得など) によって、実際にはリモートにダメージを与える動作を引き起こすような URL を記述することも場合によっては可能である。 危険な URL の典型的なものは、そのネットワークプロトコルに 予約されているポート番号とは異なるポートを指定しているものである。 URL の内容には命令が含まれていて、 そのプロトコルにしたがって解釈されたとき、 予期されない動作を引起こすのである。 例をあげると、 gopher の URL によって、意図しないメッセージや なりすましメッセージなどが SMTP サーバ経由で送信されるようなことがあった。

Caution should be used when using any URL that specifies a port number other than the default for the protocol; especially, when it is a number within the reserved space.

Care should be taken when a URI contains escaped delimiters for a given protocol (for example, CR and LF characters for telnet protocols) that these are not unescaped before transmission. This might violate the protocol, but avoids the potential for such characters to be used to simulate an extra operation or parameter in that protocol, which might lead to an unexpected and possibly harmful remote operation to be performed.

秘密にしておくべきパスワードを含んだ URI を使うのが 賢くないのは明らかである。特に、パスワードを URI の "userinfo" の部分に使うのは絶対に避けるべきである。 ただしその "password" のパラメーターを意図的に公開したい場合は別であるが。  

バグ

Documentation may be placed in a variety of locations, so there currently isn't a good URI scheme for general online documentation in arbitrary formats. References of the form <file:///usr/doc/ZZZ> don't work, because different distributions and local installation requirements may place the files in different directories (it may be in /usr/doc, or /usr/local/doc, or /usr/share, or somewhere else). Also, the directory ZZZ usually changes when a version changes (though filename globbing could partially overcome this). Finally, using the file: scheme doesn't easily support people who dynamically load documentation from the Internet (instead of loading the files onto a local filesystem). A future URI scheme may be added (e.g., "userdoc:") to permit programs to include cross-references to more detailed documentation without having to know the exact location of that documentation. Alternatively, a future version of the filesystem specification may specify file locations sufficiently so that the file: scheme will be able to locate documentation.

プログラムやファイルフォーマットの多くでは、 URI を使ったリンクを取り込んだり実装したりする方法がない。

Many programs can't handle all of these different URI formats; there should be a standard mechanism to load an arbitrary URI that automatically detects the users' environment (e.g., text or graphics, desktop environment, local user preferences, and currently executing tools) and invokes the right tool for any URI.  

関連項目

lynx(1), man2html(1), mailaddr(7), utf-8(7)

IETF RFC 2255


 

Index

名前
書式
説明
使い方
文字エンコード
URI を書くには
標準規格
注意
セキュリティ
バグ
関連項目

This document was created by man2html, using the manual pages.