A URL (Uniform Resource Locator) is a universal naming format used to indicate a resource on the Internet. It is a printable ASCII character string which breaks down into five parts:
A URL therefore has the following structure:
|Protocol||Password (optional)||Server name||Port
(optional if 80)
For example, the following protocols may be used through URL:
The name of the file in the URL can be followed by a question mark then data in the ASCII format, this is additional data sent as parameters for an application on the server (a CGI script for example). The URL will then resemble a character string like this:
Considering that the URL is a medium for sending information over the Internet (to send data with a CGI script for example), it must be able to send special characters, yet URLs cannot contain special characters. In addition, certain characters are reserved because they have a meaning (the slash enables sub-directories to be specified, the characters & and ? are used to send data via forms..). Finally, URLs can be included in an HTML document, which makes it difficult to insert characters such as < or > in the URL.
That is why encoding is necessary! Encoding consists of replacing special characters with the character % (itself also becoming a special character) followed by the ASCII code of the character to be encoded in hexadecimal notation.
Here is the list of characters which require particular encoding:
The format of URLs is defined by RFC 1738: