Forum Moderators: open

Message Too Old, No Replies

shorthand url Links

         

Kysmiley

7:15 pm on Apr 18, 2004 (gmt 0)

10+ Year Member



Can someone explain how to do shorthand links I have a page and set up a <a href="/page/"> link but want to link from one folder back to the main dir when i try to do this without using the [dir.com...] the link does not work right it puts that in and the folder i am trying to lin k out of.
Any suggestions

tedster

7:56 pm on Apr 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

Kysmiley

11:29 pm on Apr 18, 2004 (gmt 0)

10+ Year Member



Thanks for the tip i was wondering how to do that to get my html optimized further
Pat