Question mark in the middle of a URL variable

If I have a variable to pass through a URL and it has a question mark in it, do I just need to escape the question mark?

If not, how can I make sure it passes through like it's supposed to?


A question mark URL encodes as %3F. But you should use a proper encoder for the whole thing rather than manually encoding a character.


According to my experience of trying to make a JavaScript search engine that links to Google, just replace the question marks with %3F.

A URL reads the first two characters on the right of a % as hexadecimal format.


Here's a full list of URL encoding characters. If you're using PHP for a server-side language, you can use something like...

$nice_url = urlencode("http://your.old.url");

Other languages will have similar functions build in (or you can find one online). This will take care of your question mark (and other URL issues).