A McGraw Hill Book Plug-in PHP: 100 Power Solutions
By Robin Nixon (McGraw Hill 2010, ISBN 978-0071666596)

Home | About | Buy It | Download | Contact

Select Chapter: 1  2  3  4  5  6  7  8  9 10 11 12

Chapter 5: Plug-in 21 - Relative To Absolute URL

Any project that needs to crawl web pages, whether their own or third party, needs a way to convert relative URLs into absolute URLs that can be called up on their own, without reference to the page in which they are located. For example, the URL /sport/index.html means nothing at all when looked at on its own, and there is no way of knowing the URL was extracted from the web page http://server.com/news/. Using this plug-in relative URLs can be combined with the referring page to create stand-alone, absolute URLs, such as http://server.com/sport/index.html.

The Figure shows the absolute versions of several relative URLs.