Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Absolute or relative paths

Reply
Thread Tools

Absolute or relative paths

 
 
Peter Smith
Guest
Posts: n/a
 
      10-08-2007
Hi all

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
(htdocs/myproject).

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?
 
Reply With Quote
 
 
 
 
Jim Moe
Guest
Posts: n/a
 
      10-08-2007
On 10/08/07 02:10 am, Peter Smith wrote:
>
> 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
> (htdocs/myproject).
>

I have found using the "absolute" method the easiest to maintain. It
makes it simple to have a local copy of the site for development then
upload the changes without having to modify the paths.
Putting multiple site in the same root is less than optimal for
management. Give each site its own root.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      10-09-2007
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
> (htdocs/myproject).
>
> 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?

(http://www.example.com/thisdir/thatdir/what.gif)

--
Neredbojias
Half lies are worth twice as much as whole lies.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting 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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relative versus absolute paths on Windows Jason R. Coombs Python 5 11-24-2009 06:02 AM
User controls --> Relative/Absolute Paths matt.grande@gmail.com ASP .Net 0 08-10-2006 07:34 PM
distutil: problem with RELATIVE paths for install_purelib switch.. they must be ABSOLUTE?!?! Christian Seberino Python 0 10-21-2003 08:26 PM
Relative vs Absolute paths MT HTML 1 07-31-2003 10:01 PM
Convert between Windows style paths and POSIX style paths Noah Python 5 07-11-2003 09:25 PM



Advertisments