Click to See Complete Forum and Search --> : Relative Links


sharkey
10-21-2004, 09:31 AM
Hey i would like to know how relative links work ive never had to use them before but im thinking this is why my blog isnt working because i seem to be specifying the wrong folder paths.

NogDog
10-21-2004, 10:17 AM
A relative link is simply a reference to another file relative to the location of the current file. So, if our current web page is "http://www.mysite.com/dir1/dir2/mypage.html", we could do relative links to other files on our site as follows:

<!--A file in the same directory-->
<a href="anotherfile.html">

<!--A file in the www.mysite.com/dir1/dir2/img directory-->
<a href="img/picture.jpg">

<!--A file in the dir2 directory (one level up the heirarchy)-->
<a href="../one_up.html">

<!--A file at www.mysite.com//another_dir1/another_dir2/another.html-->
<a href="../../another_dir1/another_dir2/another.html>

sharkey
10-21-2004, 12:40 PM
Great NogDog just what i was looking for mate.

Thanks

ray326
10-21-2004, 02:22 PM
One thing you might run into is that servers can be set to disallow "../" in the URLs for security reasons. Doesn't happen very often so just squirrel that away "just in case."

sharkey
10-21-2004, 05:18 PM
I'll have a look at too just incase thats my blogs problems cheers for info Ray

pawky
10-22-2004, 02:34 AM
also, if you put just the / infront of the link it is referring to the home directory of the site. If you put ./ infront of the link then it refers to same folder/directory.

sharkey
10-22-2004, 06:40 AM
Kool thanks for the info aswell pawky.

Cheers again