URL variable value contains an ampersand (&)

368 views
Skip to first unread message

DR

unread,
May 27, 2011, 6:24:44 PM5/27/11
to bitly API
I'm attempting to shorten a URL that contains a variable with an
ampersand in the value. For example, the ?category=Action&Adventure

Of course, I can URL-encode the value before sending it to the bit.ly
API - unfortunately, bit.ly will decode the URL when the user opens
the shortlink.

So instead of directing the user to:
http://www.company.com/?category=Action%26Adventure (which is what I
want)

the user is sent to:
http://www.company.com/?category=Action&Adventure


Is there any workaround to this - or any other suggestions?

Thanks.

PS. I'm using bit.ly Pro

Jehiah Czebotar

unread,
May 27, 2011, 6:37:11 PM5/27/11
to bitl...@googlegroups.com
David, if you want to send the user to http://www.company.com/?category=Action%26Adventure you need to URL encode that whole string when making the shorten request.

--
Jehiah

> --
> You are subscribed to the bit.ly API discussion group.
> To post, email to bitl...@googlegroups.com
> For more options, visit http://groups.google.com/group/bitly-api

DR

unread,
May 28, 2011, 9:47:33 AM5/28/11
to bitly API
Great, that works. I didn't quite follow you at first, but now I do.

%26 will encode into %2526 (%25 is the % character), so %2526 will
then actually decode into %26 - which is what I want.

Perfect - thanks.




On May 27, 5:37 pm, Jehiah Czebotar <jeh...@bit.ly> wrote:
> David, if you want to send the user tohttp://www.company.com/?category=Action%26Adventureyou need to URL encode that whole string when making the shorten request.
>
> --
> Jehiah
>
> On May 27, 2011, at 6:24 PM, DR <da...@davidrepas.com> wrote:
>
>
>
>
>
>
>
> > I'm attempting to shorten a URL that contains a variable with an
> > ampersand in the value. For example, the ?category=Action&Adventure
>
> > Of course, I can URL-encode the value before sending it to the bit.ly
> > API - unfortunately, bit.ly will decode the URL when the user opens
> > the shortlink.
>
> > So instead of directing the user to:
> >http://www.company.com/?category=Action%26Adventure(which is what I
Reply all
Reply to author
Forward
0 new messages