title: Sharing a URL with a query string on Twitter
body: <p>I'm trying to put a Twitter share link in an email.  Because this is in an email I can't rely on JavaScript, and have to use the &quot;Build Your Own&quot; Tweet button.</p>
  <p>For example, sharing a link to Google:</p>
  <pre><code>&lt;a href=&quot;http://www.twitter.com/share?url=http://www.google.com/&gt;Tweet&lt;/a&gt;
  </code></pre>
  <p>This works fine.  The problem I'm having is when the URL has a query string.</p>
  <pre><code>&lt;a href=&quot;http://www.twitter.com/share?url=http://mysite.org/foo.htm?bar=123&amp;baz=456&quot;&gt;Tweet&lt;/a&gt;
  </code></pre>
  <p>URLs with query strings confuse Twitter's URL shortening service, t.co.  I've tried URL encoding this in various ways and cannot get anything to work.  The closest I have gotten is by doing this.</p>
  <pre><code>&lt;a href=&quot;http://www.twitter.com/share?url=http://mysite.org/foo.htm%3Fbar%3D123%26baz%3D456&quot;&gt;Tweet&lt;/a&gt;
  </code></pre>
  <p>Here I've encoded only the query string.  When I do this, t.co successfully shortens the URL, but upon following the shortened link, it takes you to the encoded URL.  I see <code>http://mysite.org/foo.htm%3Fbar%3D123%26baz%3D456</code> in the address bar, and get the following error in the browser</p>
  <blockquote>
  <p>Not Found</p>
  <p>The requested URL /foo.htm?bar=123&amp;baz=456 was not found on this server.</p>
  </blockquote>
  <p>I'm at a loss as to how to solve this problem.</p>
  <p><strong>Edit:</strong>  Re: onteria_</p>
  <p>I've tried encoding the entire URL.  When I do that no URL shows up in the Tweet.</p>