Why Your URL Broke (And How to Fix It)
URL encoding isn't optional. Here's why special characters cause problems and what to do about it.
You paste a URL into an email. Someone clicks it. They get a 404.
The URL looked fine. But somewhere between your browser and theirs, a space became %20, an ampersand disappeared, or a plus sign turned into something else entirely.
URL encoding exists because URLs can only contain certain characters. Everything else needs to be translated.
The Problem with Special Characters
URLs were designed in the early internet days with a limited character set. These are safe:
A-Z a-z 0-9 - _ . ~
Everything else? Potentially problematic.
Spaces become %20 or + depending on context. A URL with a literal space will break.
Ampersands (&) separate query parameters. If your data contains an ampersand, the URL parser thinks it's starting a new parameter.
Question marks (?) signal the start of query strings. One in your data confuses everything.
When Encoding Happens Automatically
Browsers encode URLs when you type them. That's why you can paste "new york restaurants" into Google and it works.
But automated systems often don't. APIs, scripts, email clients—they might pass your URL exactly as written. If it contains unsafe characters, it breaks.
The Double Encoding Trap
Here's where it gets annoying.
You encode a URL. Then you put it in another URL as a parameter. The system encodes it again. Now %20 becomes %2520.
When decoded, you get %20 instead of a space.
This happens constantly with redirect URLs, tracking parameters, and OAuth callbacks. If your URL looks mangled with extra percent signs, check for double encoding.
Common Encoding Mistakes
Encoding the entire URL. Don't. Only encode the values, not the structure. https:// shouldn't become https%3A%2F%2F.
Forgetting the plus sign. In query strings, + means space. If your data has a literal plus sign, it needs encoding or it disappears.
Assuming encoding is idempotent. Encoding an already-encoded string produces different output. Check if something's encoded before encoding it.
Practical Examples
A search query with spaces:
Before: https://example.com/search?q=new york pizza
After: https://example.com/search?q=new%20york%20pizza
A callback URL as a parameter:
callback = https://mysite.com/auth?token=abc
Encoded: https%3A%2F%2Fmysite.com%2Fauth%3Ftoken%3Dabc
An email address in a URL:
Before: user+tag@example.com
After: user%2Btag%40example.com
Debugging URL Issues
Check the actual request. Browser dev tools show you what's being sent. Compare it to what you expected.
Decode and inspect. If a URL isn't working, decode it to see what the server is actually receiving.
Test with special characters. Include spaces, ampersands, and plus signs in your test data. If it works with "test" but fails with "test & verify", you have an encoding issue.
URL encoding is one of those things that works invisibly until it doesn't. Understanding the rules helps you debug faster when URLs mysteriously break.