Site Root Relative References

Dreamweaver terms links that begin with a / "site root relative references"; in these references, the / refers to the root (top level) of the site.. Some other sources consider these references to be absolute, just like a reference that begins with http:// is an absolute reference. In contrast to relative references where the reference depends not only on what one is linking to but the location of the file that one is linking from, site root relative references do not change as the file that one is linking from is moved within the site. For example, consider a site with a file named first.html at the root level of the site, and a folder called news at the root level containing two files second.html and third.html A relative link from first.html to second.html would be <a href="news/second.html"> ... whereas a relative link from third.html to second.html would be <a href="second.html">... By contrast, the site root relative reference from first.html to second.html and from third.html to second.html is the same: <a href="/news/second.html">...

Although such site relative references thus appear to be simpler to construct, the problem lies in the fact that what is considered the site root can vary from server to server. This means that site relative references lack one of the major advantages of relative references, i.e., the references do not change when the site is hosted at different places.

For example, the web page you are reading appears in a folder called WWWDesign which is one of the folders at the top level of this site as I have constructed it on my hard drive.. In this folder, there is also a web page named 226bio.html.

To see the problem, view the current page at several different locations and notice how the URL of the link changes depending on what is considered the root of the site:

www.erols.com/wpegram/WWWDesign/siterootrelative.html (Erols site). Here the root of the site is www.erols.com as can be seen by the link to the root so the site root reference is <a href="/wpegram/WWWDesign/226bio.html">, thus /wpegram/WWWDesign/226bio.html is the link that will work from this site.

www.nvcc.edu/home/wpegram/WWWDesign/siterootrelative.html (NVCC Faculty server). Here the root of the site is www.nvcc.edu so as can be seen by the link to the root so the site root reference is <a href="/home/wpegram/WWWDesign/226bio.html"> thus /home/wpegram/226bio.html is the link that will work from this site.

www.student.nvcc.edu/home/wpegram/WWWDesign/siterootrelative.html (NVCC Student server). Here the root of the site is www.student.nvcc.edu as can be seen by the link to the root so the site root reference is <a href="/home/wpegram/WWWDesign/226bio.html"> thus /home/wpegram/WWWDesign/226bio.html is again the link that will work from this site.

Thus the site root relative reference changes depending on where the page is hosted and thus site relative references lose a principal advantage of relative references. The reference /WWWDesign/siterootrelative.html does not work on any of the servers above, since the site root is higher in the directory structure in each case.

An additional disadvantage of site root relative references, as noted in the Dreamweaver help screen, is that they the are intended to refer to the server and thus may not work if the file is viewed locally in the browser, e.g by double clicking on the file or by using File, Open in the browser. For example none of the site root relative links above work on this file when viewed locally.

Revised: June 2, 2003. Comments to William Pegram, wpegram@nvcc.edu