Component | Value | Description | |
---|---|---|---|
Protocol | - | The protocol used (e.g., http, https) | |
Username | - | Optional username in URL authentication | |
Password | - | Optional password in URL authentication | |
Domain | - | The domain or hostname | |
Port | - | Optional port number | |
Path | - | The path to the resource | |
Query Parameters | - | Parameters passed to the server | |
Hash/Fragment | - | Anchor to a specific part of the page |
URL encoding converts characters that are not allowed in URLs to character-entity references. Spaces are converted to plus signs (+) or %20, and reserved characters like ?, &, #, etc. are converted to their hexadecimal values.
When to use URL encoding: When you need to send data in a URL (like form submissions, API calls) or when creating links with special characters in the parameters.