Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > relative links and such

relative links and such
Thread Tools
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status: Offline
Reply With Quote
Jan 3, 2003, 09:38 AM
 
I usually use relative links to navigate between site pages and have never had many problems before. I am developing a page on my Mac using the http://127.0.0.1 address. I can use the ./ and ../ constructs to remain in the same directory or go up a directory, respetively, but I thought something like this /foo/bar.gif would start at the home directory, then go into the folder 'foo' and find the file 'bar.gif'. Whenever I try and use this form, it never finds the file that I need. Is there something specific that I need to do? If my site is contained in http://127.0.0.1/~eric how would I access a folder in the root directory?
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jan 3, 2003, 10:14 AM
 
The thing is, a URL is not necessarily a directory reference. It looks like one (this was deliberate), and there is often a fairly good correspondence, but it doesn't quite hold.

You're mostly sunk, I'm afraid. If you need to get back to your DOCUMENT_ROOT without knowing where your own page is, you have to use absolute URL's.

There is something you can do to spare yourself some pain, though. HTML has a tag called BASE. You can put this in the HEAD of your document, and use it to determine the "starting point" for all relative URL's in that page. You can put this tag into a server-side include and then include that in all the files which need it, and then if you ever have to change the URL for your DOCUMENT_ROOT you only have to change the one file and it'll be reflected in all of them.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
milf  (op)
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status: Offline
Reply With Quote
Jan 3, 2003, 10:22 AM
 
Okay, thanks. I'll look up more on this [base] tag. Thanks for the info.
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:00 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2