Re: Absolute or relative paths

Well bust mah britches and call me cheeky, on Mon, 08 Oct 2007 09:10:02 GMT
Peter Smith scribed:

I've noticed that some websites use absolute paths when linking to local
files, e.g. '/', '/style.css, '/images/logos/header.gif' etc., which has
the advantage that pages in subdirectories can use the same paths as
pages in the root, but also has the disadvantage that the site has to be
developed in the root folder (htdocs) rather than a subdirectory

And some sites use relative paths ('images/logos/header.gif' or
'../images/logos/header.gif' if the page is in a subdirectory of the
root) which has the advantage that the site can be put in any directory
and the paths will work, but the disadvantage that calling functions
that create HTML or including chunks of HTML can be a problem because
the paths will need to change depending on the directory of the page
using the HTML.

Other sites seem to use a combination -- linking relatively to some
files but absolutely to others.

I'm never really sure which route to take. Are there reasons for
choosing absolute or relative paths that I'm not aware of?

If you're worried about it, why not use absolute urls?


Half lies are worth twice as much as whole lies.

Relevant Pages

  • Re: bye-bye holly hack...
    ... As far as I can see, there is a difference between the DOM and CSS Recommendations regarding what constitutes the "root of the document tree". ... The Document interface represents the entire HTML or XML ...
  • RE: Shell prompt
    ... was visible that you was logged in as root. ... skeleton .bashrc did fix it for root? ... missing PS1 set as a normal user? ... [root@aabento html]# ...
  • Re: references
    ... I am working with a JSP page that resides in folder "X" in the root, ... and includes a .HTML page from the root folder itself. ... The my problem is that when it references the HTML file from the root ...
  • Re: Includes in libraries
    ... Regarding this well-known quote, often attributed to Tim Tyler's famous ... > I don't want lots of includes in my HTML. ... > an HTML file some distance from the root. ...
  • Re: root group in solaris
    ... it gives the user permission to do whatever he wants (which isn't ... I generally take the view that if you can't trust the users with root ... more absolute form "root can do anything", ... STSM, Informix Database Engineering, IBM Information Management Division ...