Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Url 在查询字符串中传递GET参数_Url_Query String - Fatal编程技术网

Url 在查询字符串中传递GET参数

Url 在查询字符串中传递GET参数,url,query-string,Url,Query String,我需要做两件事: 将两个参数传递给querystring 重定向到其中一个参数中给定的URL 其中一个参数是redirect=URL\u here。 问题是,我必须重定向到该页面:/about/me?look=1&sort=asc 然后,我的URL看起来像: /mypage/?letter=S&redirect=/about/me?look=1&sort=asc 我知道这是错误的(包含两个“?”)。 问题是,如何正确地生成该查询字符串?URL对查询字符串值进行编码。更改=在

我需要做两件事:

  • 将两个参数传递给querystring
  • 重定向到其中一个参数中给定的URL
其中一个参数是
redirect=URL\u here
。 问题是,我必须重定向到该页面:
/about/me?look=1&sort=asc
然后,我的URL看起来像:

/mypage/?letter=S&redirect=/about/me?look=1&sort=asc
我知道这是错误的(包含两个“?”)。
问题是,如何正确地生成该查询字符串?

URL对查询字符串值进行编码。

更改
=
在链接上用自己喜欢的
|
签名。在您的情况下,像这样更改链接
/about/me?look | | 1&sort | | | asc

然后,稍后您将使用
=

使用Url编码更改
|

像这样

<script>
var c= 'd e'
var query= '?a=b&c='+encodeURIComponent(c);
var uri= 'http://www.example.com/script?query='+encodeURIComponent(query);
window.location= uri;
</script>

要解码

没有办法将JS放在任何地方。我唯一能做的就是准备合适的查询字符串——它在封闭系统中使用,代码不能更改。然后替换你的?使用其他特殊字符,如mypage/?letter=S&redirect=/about/me*look=1^sort=asc,有什么好处?如果我将look=1&改为look=1^那么它将如何工作?
 decodeURIComponent()