Re: Full versus relative URLs
| From: | German Geek | Date: | Mon, 16 Feb 2009 20:33:33 +0000 |
| Subject: | Re: Full versus relative URLs | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-288373@lists.php.net to get a copy of this message | ||
Tim-Hinnerk Heuer
http://www.ihostnz.com
Mike Ditka - "If God had wanted man to play soccer, he wouldn't have given
us arms."
2009/2/17 Paul M Foster <paulf@quillandmouse.com>
> On Mon, Feb 16, 2009 at 07:39:29PM +0200, Thodoris wrote:
>
> >
> >> Here's a question related to my last post. When specifying a link in a
> >> HTML file (like to the css or an image file), there are two ways of
> >> doing it. One is to simply include the relative path to the file
> >> (relative to the doc root), like:
> >>
> >> /graphics/my_portrait.gif
> >>
> >> Or you can include the full URL, like:
> >>
> >> http://example.com/graphics/my_portrait.gif
> >>
> >> My casual observation seems to indicate that the former will load faster
> >> than the latter. But has anyone done any benchmarking on it?
> >>
> >> Paul
> >>
> >>
> >
> > I am not aware if absolute URLs are faster or not (in case they are
> > there will be such a small difference you cannot probably notice) but
> > IMHO it is a bad practice to use full URLs.
> >
> > Basically because renaming directories or scripts will cause great pain
> > in the ass.
> >
> > Of course resources that are coming outside your own site are needed to
> > use absolute URLs and nobody is assuming that are useless.
>
> Agreed. But here's the real reason, in my case. We develop the pages on
> an internal server, which has the URL http://pokey/mysite.com.
> When we
> move the pages to the live server at mysite.com, all the URLs would have
> to be rewritten. Ugh.
>
In that case you could change your hosts file (unix: /etc/hosts windows:
%windir%\system32\drivers\etc\hosts) and add a line with the live server's
ip like so:
123.456.789.12 www.example.com
and all your URLs would be right. When you need to check the live domain,
you can simply comment out that line with #.
;) Hope this helps a few people. Saved me a lot of grief.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>