Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Relative vs. absolute URLs

Reply
Thread Tools

Relative vs. absolute URLs

 
 
Kyle James Matthews
Guest
Posts: n/a
 
      05-11-2004
Does it make a difference in terms of loading time, browser caching, etc. to
use absolute vs. relative URLs and image file names? I am using a PHP
include to put my main navigation on many pages in many different folders,
and to do so I am forced to define pages within my site as well as images
absolutely (i.e. http://...). Unless there is another solution I am not
aware of.

Standard disclaimer: sorry if I missed anything while googling, relevant
URLs appreciated, etc. etc.

Kyle


 
Reply With Quote
 
 
 
 
Lauri Raittila
Guest
Posts: n/a
 
      05-11-2004
Kyle James Matthews wrote:
> Does it make a difference in terms of loading time, browser caching, etc. to
> use absolute vs. relative URLs and image file names?


No, exept that absolute urls tend to be longer, ie. loading slower. If
you had 300baud modem, you might notice difference.

> I am using a PHP
> include to put my main navigation on many pages in many different folders,
> and to do so I am forced to define pages within my site as well as images
> absolutely (i.e. http://...). Unless there is another solution I am not
> aware of.


There is. PHP is programming language, of course you can program
something to do make them relative. I don't think it is worth hasle
trough. Anyway, why not make them relative to domain root
(/foo.bar = http://foo.example/foo.bar when used in foo.example)

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
I'm looking for work | Etsin työtä
 
Reply With Quote
 
 
 
 
Jeff Thies
Guest
Posts: n/a
 
      05-11-2004
> Anyway, why not make them relative to domain root
> (/foo.bar = http://foo.example/foo.bar when used in foo.example)


Usually that's refered to as an absolute path.

Absolute paths work well when you don't know what directory you may be in
(or don't care).

It's a matter of the site architecture, personal style and whether you need
to view these locally or in a different environment whether to use relative
or absolute paths.

Jeff
>
> --
> Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
> I'm looking for work | Etsin työtä



 
Reply With Quote
 
j
Guest
Posts: n/a
 
      05-11-2004
> Does it make a difference in terms of loading time, browser caching, etc. to
> use absolute vs. relative URLs and image file names? I am using a PHP
> include to put my main navigation on many pages in many different folders,
> and to do so I am forced to define pages within my site as well as images
> absolutely (i.e. http://...). Unless there is another solution I am not
> aware of.
>
> Standard disclaimer: sorry if I missed anything while googling, relevant
> URLs appreciated, etc. etc.
>


are you saying you are doing an include like:
<?php
include "http://www.yoursite.com/includes/filetoinclude.php" ;
?>

You don't need to do that. If you have lots of pages with the same
include just do it as a full path:

/yourhomedirectory/yourhtmlfiles/yourincludes/filetoinclude.php

If i recall sometimes you might need something like
[SERVER_document_root] first (note that is _not_ correct syntax for
that)

Anyway you don't have to make an external request to your own website
which is what you would be doing in the first example.

You can also use relative URLs like ../ or
.../myincludes/filetoinclude.php but they can be a pain in the ass if
you have a lot of different files all over the place who's path to the
include will be different

If you are doing includes based on user input make sure you check what
people are including first and make a very tight set of criteria that
it must pass

otherwise:

http://www.yoursite.com/yourfile.php...evilsite.com/m
yevilfile.php

regards
 
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
Converting Relative URLs into Absolute URLs Nathan Sokalski ASP .Net 1 08-12-2008 07:03 AM
relative vs absolute URLs? Flip ASP .Net 0 11-24-2005 04:53 PM
Converting relative URLs to absolute? Nick Woolley Ruby 1 06-30-2005 01:25 AM
Relative/Absolute URLS theo HTML 17 02-09-2005 06:06 AM
Invalid URL form or fully-qualified absolute URL was used. Use relative URLs Rudi Ahlers ASP General 11 04-11-2004 03:17 PM



Advertisments