URL encoding, also known as percent encoding, is the process of converting characters that are not allowed in URLs into a universally accepted format. Special characters, spaces, and non-ASCII characters are replaced with a percent sign followed by two hexadecimal digits representing the character's ASCII or UTF-8 byte value. For example, a space becomes "%20" and an ampersand becomes "%26."
URL encoding is defined by RFC 3986, which specifies which characters are allowed in different parts of a URL. Unreserved characters (A-Z, a-z, 0-9, hyphen, period, underscore, tilde) can appear as-is, while reserved characters that have special meaning in URL syntax must be encoded when used as data rather than delimiters. Web standards books on Amazon explain these specifications.
In URL shortening, encoding is relevant in two contexts. First, the destination URL submitted for shortening may contain encoded characters that must be preserved during storage and redirect. Second, the short URL itself should avoid characters that require encoding, which is why most services restrict short codes to alphanumeric characters and hyphens.
Common pitfalls include double encoding (encoding an already-encoded URL), inconsistent encoding of Unicode characters, and failing to encode query parameter values. These issues can cause broken redirects or incorrect destination pages. Web development debugging books on Amazon cover troubleshooting techniques.