Forum Moderators: phranque

Message Too Old, No Replies

absolute path?

         

charonlee

7:43 am on Mar 27, 2003 (gmt 0)

10+ Year Member



when we start a link with slash, i.e <a href="/dir/file,asp">, <img SRC="/images.jpg">, can we say that they are
absolute path.

i'm here have a question, I found that when we create our link as above (start with slash), it has two meaning,
1.) Start from root directory of the webs-site
2.) Start from a Virtual Directory call /dir

If the situation is 2, then it might point to wrong location.

Please advice.

deejay

8:30 am on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Charonlee

I would say what you ahve there is a relative URL... it's going to try to go to the directory/file from its present location.

www.mydomain.com/files/123.html = absolute URL

/files/123.html = relative URL

You can get away from the problem of relative URLs by putting a 'base href' the head section of your page:

<base href="http://www.mydomain.com.com/">

That way any relative URLs will be read as starting from the 'base href'.

charonlee

8:49 am on Mar 27, 2003 (gmt 0)

10+ Year Member



guess, you are wrong..
please read URL:http://www.asp101.com/resources/paths.asp

griz_fan

4:46 pm on Mar 27, 2003 (gmt 0)

10+ Year Member



The approach I've taken involves three options:
1. relative pathing (../dir/file.html)
2. abosolute pathing (http://www.website.com/dir/file.html)
3. Root-relative pathing (/dir/file.html)

I've found that if your site has a deep directory structure or if you use includes, option 3 works the best. If you have, say, an include for your header, and that header has image links, root relative pathing will ensure that these image links (/images/headerimg.gif for example) will still work no matter if the file calling the header include is in the root or nested 5 or 6 directories deep.

Hope this helps!

andreasfriedrich

4:54 pm on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For the correct terms and usage see my post in Path Information - The Base Element - <base href="http://www.domain.com/"> [webmasterworld.com].

Andreas