Absolute urls, relative urls, and...?
Here are the URL components:
http://www.example.com/en/public/img/logo.gif
\__/ \_____________/\_____________________/
#1 #2 #3
- scheme/protocol
- host
- path
A URL is called an absolute URL if it begins with the scheme and scheme specific part (here //
after http:
). Anything else is a relative URL.
A URL path is called an absolute URL path if it begins with a /
. Any other URL path is called a relative URL path.
Thus:
-
http://www.example.com/en/public/img/logo.gif
is a absolute URL, -
../../public/img/logo.gif
is a relative URL with a relative URL path and -
/en/public/img/logo.gif
is a relative URL with an absolute URL path.
Note: The current definition of URI (RFC 3986) is different from the old URL definition (RFC 1738 and RFC 1808).
The three examples with URI terms:
-
http://www.example.com/en/public/img/logo.gif
is a URI, -
../../public/img/logo.gif
is a relative reference with just a relative path and -
/en/public/img/logo.gif
is a relative reference with just an absolute path.
I have seen it called a root relative URL.
From the Microsoft's documentation about Absolute and Relative URLs
A URL specifies the location of a target stored on a local or networked computer. The target can be a file, directory, HTML page, image, program, and so on.
An absolute URL contains all the information necessary to locate a resource.
A relative URL locates a resource using an absolute URL as a starting point. In effect, the "complete URL" of the target is specified by concatenating the absolute and relative URLs.
An absolute URL uses the following format: scheme://server/path/resource
A relative URL typically consists only of the path, and optionally, the resource, but no scheme or server. The following tables define the individual parts of the complete URL format.
scheme - Specifies how the resource is to be accessed.
server - Specifies the name of the computer where the resource is located.
path - Specifies the sequence of directories leading to the target. If resource is omitted, the target is the last directory in path.
resource - If included, resource is the target, and is typically the name of a file. It may be a simple file, containing a single binary stream of bytes, or a structured document, containing one or more storages and binary streams of bytes.