Question mark in the middle of a URL variable

HtmlUrlVariables

Html Problem Overview


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?

Html Solutions


Solution 1 - Html

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

Solution 2 - Html

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.

Solution 3 - Html

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).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontownieView Question on Stackoverflow
Solution 1 - HtmlDavid SchwartzView Answer on Stackoverflow
Solution 2 - HtmlElectroBitView Answer on Stackoverflow
Solution 3 - HtmlDorkRawkView Answer on Stackoverflow