URI (Uniform Resource Identifier)
- Introduction to URIs.
- Fragment identifiers.
- Relative URIs.
1. Introduction to URIs.
The World Wide Web (Web) is a network of information
resources. Every resource available on the Web -- HTML document,
image, video clip, program, etc. -- has an address that may be encoded
by a Universal Resource Identifier, or "URI".
URIs typically consist of three pieces:
- The naming scheme of the mechanism used to
access the resource (e.g. http: ftp: mailto:).
- The name of the machine hosting the resource.
- The name of the resource itself, given as a path.
Consider the following URI:
http://www.pmg3.com/varna/school/index.htm
This URI may be read as follows: There is a document index.htm
available via the HTTP protocol, residing on the machine
www.pmg3.com, accessible via the path /varna/school/.
Other schemes you may see in HTML documents include "mailto:" for email
(e.g. mailto:pmg3@revolta.com) and "ftp:" for FTP.
2. Fragment identifiers.
Some URIs refer to a location within a resource. This kind of URI ends
with # followed by an anchor identifier (called the
fragment identifier).
For instance, here is a URI pointing
to an anchor named pos2 in the file index.htm:
http://www.pmg3.com/varna/school/index.htm#pos2
3. Relative URIs.
A relative URI doesn't contain any naming scheme
information. Its path generally refers to a resource on the
same machine as the current document. Relative URIs may contain
relative path components (e.g., ".." means one level up in the
hierarchy defined by the path), and may contain fragment identifiers.
For example, if the following directory structure resides on the
machine www.pmg3.com:
|
|--pictures
| mary.jpg
| steve.gif
|
|--varna
| | city.htm
| |
| |__sea
| | boat.htm
| |
| |__school
| index.htm
| present.htm
and the document index.htm contains links pointing to files
mary.jpg, city.htm, boat.htm, present.htm,
instead of full URIs:
http://www.pmg3.com/pictures/mary.jpg
http://www.pmg3.com/varna/city.htm
http://www.pmg3.com/varna/sea/boat.htm
http://www.pmg3.com/varna/school/present.htm
the following relative URIs, may be used:
../../pictures/mary.jpg
../city.htm
../sea/boat.htm
present.htm
Relative URIs are resolved to full URIs using a base URI
(the URI of the current document).
For easy transition of files to another machine the
use of relative URIs is recommended.
IMPORTANT!!!
Servers are UNIX based machines, so URIs are
case-sensitive.
For example, the following URIs are all different:
http://www.pmg3.com/varna/school/present.htm
http://www.PMG3.com/varna/school/present.htm
http://www.PMG3.com/Varna/School/Present.HTM
Note: Most readers may be familiar with
the term "URL" and not the term "URI". URLs form a subset of the
more general URI naming scheme.