Forum Moderators: open
GOING TO THE ROOT DIRECTORY
If you precede a filename with a forward slash /
that means start at the root of the domain to locate the file.
So this:<a href="/page.html">
...means...
<a href="http://www.example.com/page.html">
GOING "UP" ONE DIRECTORY
If you precede a filename with ../
that means "go one directory toward the root from where
this link occurs."So if you are creating an anchor on a page located in
www.example.com/dir1/dir2/, then:<a href="../page.html">
...means...
<a href="http://www.example.com/dir1/page.html">
GOING "UP" MANY DIRECTORIES
You can repeat as many instances of ../ as you need,
for example:<a href="../../page.html">
...means...
<a href="http://www.example.com/page.html"
In general, I find that ../ can become difficult to maintain because I like to copy/paste code snippets around the site. It's not very portable because I often forget to copy files up the directory tree or change the number of ../ I use on a given page. For this reason, I follow a rule of using relative URLs only when they point to a resource in the same directory or one of its sub-directories.