A URL describes the location of a file. A complete URL includes the server, all of the path (list of directories) and the filename.
An absolute reference to a URL starts with the type of service, which is http://" for web pages, followed by the server, a slash (/), and the name of each directory and the filename.
The absolute reference to this page would be: http://www.ces.ncsu.edu/depts/it/itaids/publish/012/index.html
This type of URL reference bears no relationship to the location of the html file containing the anchor tag. An anchor tag using the above URL would link to this page, regardless of which server or which directory the referencing page was located.
To save a lot of typing and corrections when moving or renaming files, it is often easier to use relative references to URLs. Relative to the directory If the URL of the page you are linking to is in the same directory as the page containing the link (the current directory), all that's needed for the URL is the filename. link to the "Referencing URLs" page
If the page being linked to is in a subdirectory of the same directory, start the URL with the subdirectory name. For example the link to this page from http://www.ces.ncsu.edu/depts/it/itaids/page.html is:
Referencing URLs Relative to the web server
If the URL of the page you are linking to is on the same web server as the page containing the link, you can indicate the URL by starting at the root directory of the web server by starting your reference with a "/". For example:
Referencing URLs from anyfile on the http://www.ces.ncsu.edu/ server. URL Where the file "anyfile.html" is found anyfile.html in the same directory anydirectory/anyfile.html in the subdirectory "anydirectory" of the current directory /anydirectory/anyfile.html in the subdirectory "anydirectory" of the same web server http://www.domain.edu/directory/subdirectory/anyfile.html on the server "www.domain.edu" in the directory "directory/subdirectory" Referencing index.html or index.shtml (or the default) files on the NCCE servers.
When no filename is given in a URL, the browser will display all the files and directories in the directory indicated (or a default page usually indicating that the page requested does not exist). If, however, the directory contains a file with the default name (in our case: "index.html" or "index.shtml") the server will send that file.
This has several implications. Some reasons you may want to do this:
- Usually the index.html page is used as an "Index" page to a particular section of a web site.
- Reduce typing. To reference an index.html or index.shtml file you can stop with the slash (/) preceding the filename. For example if you wanted to link to the index.html page in the web server's root directory you would use the anchor tag:
- Work in progress. You may have files that aren't ready for "prime time" yet, but want them in the correct directory so you can verify all the relative references in the page. By: John Dorner, IV, Area Specailized Agent, Information Management