HTML help - how to (relatively) link to a higher directory

Ansi

Experienced
Joined
Jan 12, 2004
Posts
55
I'm trying to code a series of simple webpages for a project I'm working on. Basically, I'm making a series of pages and files to be unzipped onto a person's hard drive, then accessed via links from a base index page. Since the files will be on the person's drive (and not online) I can't make 'absolute' links to anything...it all has to be relative (such as "link to the IMAGE.JPG file in the EXAMPLE subdirectory in the directory this page is in). HTML gurus should know what I mean.

Here's the trouble...I know how to link to a file that's in a subdirectory, by adding the subdirectory to the path to the filename (i.e. SUBDIRECTORY\FILENAME.BLA). However, I don't have a clue how to link to a file that's in a *higher* directory than the current one.

Let's say I have an index page that links to another page in a subdirectory. How can I make a link on that page that links BACK to the index page? I don't know how make the appropriate path, since relative paths can (seemingly) only point to files or subdirectories inside the current directory, NOT anything above it.

Can anyone help me out here?
 
Ansi, here's what my husband says...I hope it helps!

If I remember correctly, you will need to add two periods prior to the directory forward slash. Like:
../filename.bla

The two periods and the forward slash tell the browser to look in the directory above.
 
Ansi said:
Let's say I have an index page that links to another page in a subdirectory. How can I make a link on that page that links BACK to the index page? I don't know how make the appropriate path, since relative paths can (seemingly) only point to files or subdirectories inside the current directory, NOT anything above it.

Can anyone help me out here?

HTML has a command to set the base directory.

If you use that command, every URL that doesn't begin with HTTP:// will be referenced from the same base directory.

For example if you set the base directory to "/home" every relative URL you use will be referenced from "/home."

Instead of a reference to "images\next.jpg" looking in "<current-dir>/images" a base referenced page would look in "/home/images" for "next.jpg."

On any windows/MSDos machine, the directories "." and ".." are the current and parent directories respectively, but I don't know that those will work on all versions of UNIX/LINUX or MAC OS. If you know the pages you're writing will be used on a Windows basd PC, then you can use them. I have no idea how reliable they'd be on any other platform.
 
Thanks, Erika...that info is exactly what I was after. Tell your hubby "thanks" from me. :)







*stares at Erika'a avatar for a while*
 
Ansi said:
Thanks, Erika...that info is exactly what I was after. Tell your hubby "thanks" from me. :)







*stares at Erika'a avatar for a while*

He said you're welcome...such a nerd, but I love him to pieces! :D
 
Back
Top