Reputation: 7009
say I want to set the URL: www.a.com?str1=12&str2=67
as a parameter in another URL so that it can be parsed properly.
problem: say i set it as a parameter in another url as-
www.a.com?redirect_to=www.a.com?str1=12&str2=67
then what happens is when I parse the url then I get the value of redirect_to
as www.a.com?str1=12
because strt2
is considered to be another parameter. so what can I do to get www.a.com?str1=12&str2=67
as the value of redirect_to
?
Upvotes: 0
Views: 31
Reputation: 3760
Try escaping the redirect url with CGI.escape:
require 'cgi'
my_url = "www.a.com?redirect_to=#{CGI.escape('www.a.com?str1=12&str2=67')}"
# my_url => "www.a.com?redirect_to=www.a.com%3Fstr1%3D12%26str2%3D67"
Upvotes: 1