正在转发具有重写规则的查询字符串



我正在尝试编写重写规则,但在转发查询字符串时遇到了一些严重问题。我也尝试过[QSA]标志,但它不起作用。

按照正确的要求:

/localhost/registry/registry.php?id=something&password=somethingelse&uri=whatever

我会变成这样:

/localhost/registry/register

使用相同的post查询(id=something&password=somethinggelse&uri=whatever)。此时,我的.htaccess会将上述请求修改为以下请求:

/localhost/registry/registry.php?request=register&id=something&password=somethingelse&uri=whatever

然后,我在.htaccess:中尝试了以下重写规则

RewriteRule ^register$ http://localhost/registry/registry.php?request=$0&$1 [QSA]

但是,在最后一个"&"之后,没有显示任何内容,$1变量为空。我必须写什么样的重写规则?

提前谢谢。

!!!解决方案

RewriteRule ^register$ /registry/registry.php?request=$0 [QSA]
RewriteRule ^register$ /registry/registry.php?request=$0  [QSA]

如果转到http://localhost/registry/register?id=1,那么查询字符串将是(来自php):

array(2) {
  ["request"]=>
  string(8) "register"
  ["id"]=>
  string(1) "1"
}

最新更新