File
|
URLs
Uniform Resource Locator
, or
URL
, is a fancy
The first part of the URL is called the
scheme
. It
Figure 1.16. Your basic URL contains a scheme, server name,
|
|
File name |
Absolute URL (can be used
|
Relative URL (only works in youarehere.html) |
|---|---|---|
|
index.html |
www.site.com/web/index.html |
index.html |
|
image.gif |
www.site.com/web/images/image.gif |
images/image.gif |
|
data.html |
www.site.com/
|
../info/data.html |
|
homepg.html |
www.remote.com/pub/homepg.html |
(none: use absolute) |
|
info.html |
www.remote.com/bcn/info.html |
(none: use absolute) |
To give you directions to my neighbor's house, instead of giving her complete address, I might just say "it's three doors down on the right". This is a relative addresswhere it points to depends on where the information originates. With the same information in a different city, you'd never find my neighbor.
In the same way, a relative URL describes the location of the desired file with reference to the location of the file that contains the URL itself. So, you might have the URL say something like "show the xyz image that's in the same directory as this page".
The relative URL for a file that is in the same directory as the current page (that is, the one containing the URL in question) is simply the file name and extension (Figure 1.ch01fig22) . You create the URL for a file in a subdirectory of the current directory by typing the name of the subdirectory followed by a forward slash and then the name and extension of the desired file (Figure 1.ch01fig23) .
To reference a file in a directory at a higher level of the file hierarchy, use two periods and a forward slash (Figure 1.ch01fig24) . You can combine and repeat the two periods and forward slash to reference any file on the same hard disk as the current file.
Generally, for files on the same server, you should always use relative URLs. They're much easier to type and they make it easy to move your pages from a local system to a server. As long as the relative position of each file remains constant, the links will work correctly.
One added advantage of relative URLs is that you don't have to type the schemeas long as it's HTTP.