Ech,我的查询字符串看起来像:
http://localhost/index.php?page=public&another=http://www.google.com?omg=tt&nop=asd
然后我用regex重写它:
正则表达式:
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)这样做? 最大的问题是如何在查询字符串中传递两个问题和&符号? 有关这种情况的任何建议吗?
答案 0 :(得分:0)
问题在于您的重写规则。喜欢这样:
RewriteRule ^pass-([^=]*)=([^=]*)$ hw.php?page=$1&another=$2 [L,QSA]
请注意额外的QSA标记,以确保保留原始查询参数。