2011-11-03 92 views
0

ECH,我的查询字符串看起来像:查询字符串中有两个问号和两个&符号?

http://localhost/index.php?page=public&another=http://www.google.com?omg=tt&nop=asd 

而且afcourse我用正则表达式来重写: 正则表达式: 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

问题出现在您的重写规则中。像这样:

RewriteRule ^pass-([^=]*)=([^=]*)$ hw.php?page=$1&another=$2 [L,QSA] 

请注意,额外的QSA标志将确保保留原始查询参数。

+0

嗯,10分钟后意识到,在PHP中存在这个: $ _SERVER ['REQUEST_URI'],所以它甚至给/ pass-url =,但与str_replace我“删除它”和网址的作品。无论如何,感谢您的帮助。 – ZeroSuf3r

相关问题