查询字符串中有两个问号和两个与号?
呃,我的查询字符串看起来像:
http://localhost/index.php?page=public&another=http://www.google.com?omg=tt&nop=asd
当然我用正则表达式将其重写为: 正则表达式: RewriteRule ^pass-([^=]*)=([^=]*)$ index.php?page=$1&another=$2 [L]
http://localhost/pass-url=http://www.google.com?omg=tt&nop=asd
(1)但是 url 变成:仅限http://www.google.com。
如果我在没有正则表达式的情况下尝试使用此网址urlencode:
http://localhost/index.php?page=public&another=http://www.google.com?omg=tt&nop=asd
它会回显:
http%3A%2F%2Fwww.google.com%3Fomg%3Dtt
(2)在这种情况下&nop=asd
部分消失了。
那么如何使(1)起作用以及为什么(2)这样做呢? 最大的问题是如何在查询字符串中传递两个问题和&符号? 对于这种情况有什么建议吗?
Ech, my query string look's like:
http://localhost/index.php?page=public&another=http://www.google.com?omg=tt&nop=asd
And afcourse i rewrite it with regex to:
regex:RewriteRule ^pass-([^=]*)=([^=]*)$ index.php?page=$1&another=$2 [L]
http://localhost/pass-url=http://www.google.com?omg=tt&nop=asd
(1)But then url becomes to: http://www.google.com only.
If i try urlencode with this url without regex:
http://localhost/index.php?page=public&another=http://www.google.com?omg=tt&nop=asd
it echo:
http%3A%2F%2Fwww.google.com%3Fomg%3Dtt
(2)In this case &nop=asd
part gone.
So how to make (1) work and why (2) do this ?
The biggest question would be how to pass two question and ampersand in query string ?
Any suggestion regarding this situation ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在你的重写规则中。像这样:
注意附加的 QSA 标志将确保保留原始查询参数。
Problem is in your rewrite rule. Have it like this:
Note that additional QSA flag which will make sure to preserve original query parameters.