URL Parameters and Percent Encoding
URL parameters (also known as query strings) are a fundamental way to pass data from a client (like a web browser) to a server. They dictate how search engines, APIs, and web forms operate.
The Structure of Parameters
Parameters always appear at the end of a URL, starting with a question mark (?). Multiple parameters are chained together using an ampersand (&). Each parameter consists of a key and a value, separated by an equals sign (=).
Example: ?sort=price_asc&category=books
The Necessity of Percent Encoding
Because the characters ?, &, and = act as structural dividers, they are reserved. If your data value contains one of these characters, the server will misinterpret the structure.
If you want to send a company name like "Smith & Sons" in a parameter, you cannot write ?company=Smith & Sons. The server will see a parameter named company with a value of "Smith ", and a second parameter named " Sons".
By applying percent-encoding, you convert the ampersand to %26, resulting in ?company=Smith%20%26%20Sons. The server now perfectly understands that this is a single, continuous string value.