Forum Moderators: open

Message Too Old, No Replies

Relative Links on Local Drive

Buggin' me out...

         

madcat

3:46 pm on Nov 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When I develop locally, not using PHP or anything, I cannot use relative links like /example/page.html. It has to be either example/page.html or ./example/page.html.

Is this right? Can I not make my links relative like this on my local computer?

sonjay

5:32 pm on Nov 2, 2005 (gmt 0)

10+ Year Member



That type of link ("/example/page.html") is an absolute path from the site's document root. Your computer doesn't know what the site's document root is. The other examples you gave (example/page.html or ./example/page.html) are relative to the current document, which is why they work when you simply open the file in your browser on your own computer.

This type of link will work locally if you set up Apache or some other web server on your computer, and call your pages from within the server (i.e., http://localhost.com/example/page.html).

[edited by: encyclo at 5:48 pm (utc) on Nov. 2, 2005]
[edit reason] removed live link [/edit]

rocknbil

11:38 pm on Nov 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes but thanks to Bernard Marx, we have the trick in this thread [webmasterworld.com] that makes this cease to be a problem. :-)

They're talking about Javascript, but down toward the bottom is a solution that should apply here too.

madcat

3:50 pm on Nov 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well thanks, I will look into it.