URLs - Absolute
paths and relative paths. What is the difference between the two?
Great question!
This is a major source of confusion and is easily explained. (The
trick is to know that ../ means go up a directory!) ../../media means
go up two directories and over to the media directory.
Think about this:
If you live at 1000 HTML Street you next door neighbour might be 1002
HTML Street. A block over might be 1000 Media Street. A block down
might be 1010 HTML Street (but it is still on HTML Street!!) In HTML
a RELATIVE path is "relative" to you. So your neighbor would
be "1 house down on the same block". The person living one
block over would be "one block over." You would express
this same concept in the filename as "1.html" (for your
neighbour) or "../media/1.jpg" for the media file that is
"up one level" - which is the same thing as "over one
block" in the phisical world. The person a block down would be
on the same street (directory) but on a new block (subfolder). If
we name the subfolders lessons the lessons.html file could be found
from your house by going to lessons/lessons.html
Absolute paths
are the "fully qualified" addresses. So your neighbor would
be 1001 Page and the block over would be 1001 Media. But in HTML it
would be http://www.yvod.com/html/1.html or http://www.yvod.com/media/1.jpg
and the person down the block would be http://www.yvod.com/html/lessons/lessons.html
Why use one
or the other?
Absolute paths
are used by people who do not know how to code properly. It is a simple
as that. The ONLY reason to use absolute paths is if you do not own
the content you are working with and need to grab it from a server
that needs a fully qualified URL. We are working with a major corporation
that just does not understand this. They are spending, literally,
10's of thousands of dollars hunting down broken links because they
insists on using absolute paths.
Relative paths
are wonderful because you can set everything up in a main folder.
Then... as you move that folder around, none of the links break because
the internal structure stays the same.
Site Structure:
YVOD's Method (all lowercase -
never use spaces)
|
project_folder
|
|
html
|
media
|
|
features
site_construction news
|
flash
quicktime photos realmedia
|
Put
ALL your html files in the html folder or subfolders within the html
folder. Put all your media in the media folder or subfolders of the
media folder. Then all you have to do is upload the html and media
folders into the main site folder and all the links will work and
your directories will stay intelligible.
If you are working
with quicktime (for example) you can create a directory INSIDE the
media folder called quicktime and place all your quicktime work in
there. To reference it from an html file inside the site_construction
directory called site_construction.html you would do this:
../../media/quicktime/quicktime.mov
This means...
go up two levels, go over and down into the media folder, go down
into the quicktime folder, and grab the quicktime movie. The absolute
paths to the two files would be:
http://www.yvod.com/html/site_construction/site_construction.html
http://www.yvod.com/media/quicktime/quicktime.mov
Just so you know
how complex this can become, we routinely work on sites that have
5 levels of subdirectories within the HTML folder! Additionally, we
have sql, perl-bin (or modperl), and log directories at the same
level as the html and media folders. When you are working with sites
that have over 5000 files... you need a directory structure that works
- and you NEED relative paths!