Re: Full versus relative URLs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2009-02-16 at 20:19 +0200, Thodoris wrote:
> > 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.
> >
> > Paul
> >
> >   
>  
> I sometimes use something like this in my scripts for every script to 
> determine itself:
> 
> // Find what is the name of this script
> $self = basename($_SERVER['PHP_SELF']);
> 
> You can probably take advantage of the $_SERVER information so that you 
> don't need to rewrite every url you use.
> 
> Hope that helps.
> 
I know it's been said before, but beware of relying on this value just
for the sole purpose of deciding where things are located, as without a
bit of error checking on it, it can be used for injection attacks and
what-not, although, sadly, I forget the exact post recently that had the
link that explained this issue on PHP_SELF.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux