Appendix A. Absolute and Relative URLs

When URLs were originally invented, each specified everything needed to find some resource, including the protocol to use, the path to the resource, and any extra parameters required by the protocol or resource.

A URL like this is known as an absolute URL , because it contains all this information. It can be passed around freely without needing any extra context to fetch its resource.

Absolute URLs are a problem, however, when you have a group of resources that all reference each other, such as the group of web pages that make up a complete web site. If you want to move this site to a different server, you have to go through every page looking for URLs on the old server, and change these to point to the new server.

The problem can occur even without moving the pages from one server to another. Many people test their web sites locally on their own computer, using file URLs . If these sites use absolute URLs for their cross references, all the links have to be changed before the site can be uploaded to the main server. (Apart from being inconvenient, this is also a place where errors can be introduced.)

The solution to this problem is to allow parts of the URL to be omitted. Such partial URLs are known as relative URLs . Alone, they don’t contain enough information to locate a resource; they must be converted into absolute URLs by adding the missing parts. This process is known as resolving .

A URL is resolved relative to an existing absolute URL, ...

Get Learning WML, and WMLScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.