Thursday, June 5, 2008

Reserved Characters in URLs

Reserved Characters in URLs

Character

Meaning

:

The colon is a separator that separates the protocol from the rest of the URL scheme; separates the host name from the port number; and separates the user name from the password.

//

The double slash marks indicate that the protocol uses the format defined by the Common Internet Scheme Syntax (see RFC 1738 for more information).

/

The slash is a separator and is used to separate the path from the host name and port. The slash is also used to denote the directory path to the resource named in the URL.

~

The tilde is generally used at the beginning of the path to indicate that the resource is in the specified user's public Hypertext Markup Language (HTML) directory.

%

Identifies an escape code. Escape codes are used to specify special characters in URLs that otherwise have a special meaning or aren't allowed.

@

The at symbol is used to separate user name and/or password information from the host name in the URL.

?

The question mark is used in the URL path to specify the beginning of a query string. Query strings are passed to Common Gateway Interface (CGI) scripts. All the information following the question mark is data the user submitted and isn't interpreted as part of the file path.

+

The plus sign is used in query strings as a placeholder between words. Instead of using spaces to separate words that the user has entered in the query, the browser substitutes the plus sign.

=

The equal sign is used in query strings to separate the key assigned by the publisher from the value entered by the user.

&

The ampersand is used in query strings to separate multiple sets of keys and values.

^

The caret is reserved for future use.

{}

Braces are reserved for future use.

[]

Brackets are reserved for future use.

To make URLs even more versatile, you can use escape codes to specify characters in URLs that are either reserved or otherwise not allowed. Escape codes have two components: a percent sign and a numeric value. The percent sign identifies the start of an escape code. The number following the percent sign identifies the character being escaped. The escape code for a space is a percent sign followed by the number 20 (%20). To refer to a file called "my party hat.htm," for example, you could use this escape code in a URL.

No comments: