Php 需要htaccess规则来区分目录和查询字符串

Php 需要htaccess规则来区分目录和查询字符串,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我有一个像下面提到的url abc.com/test/abc/hello/?hello=world&foo=bar 我必须使用htaccess区分目录和查询字符串 我需要这样的结果: Array ( [data] => test/abc/hello/ [hello] => world [foo] => bar ) 我已经尝试了很多htaccess方法,但没有得到我想要的结果。我试过以下方法 如果我尝试: RewriteRule ^([\w\-

我有一个像下面提到的url

abc.com/test/abc/hello/?hello=world&foo=bar
我必须使用htaccess区分目录和查询字符串

我需要这样的结果:

Array
(
    [data] => test/abc/hello/
    [hello] => world
    [foo] => bar
)
我已经尝试了很多htaccess方法,但没有得到我想要的结果。我试过以下方法

如果我尝试:

RewriteRule ^([\w\-\/]+)$ index.php?data=$1
输出:

Array
(
    [data] => test/abc/hello/
)
Array
(
    [hello] => world
    [foo] => bar
)
在尝试时:

RewriteRule .* test.php [L]
输出:

Array
(
    [data] => test/abc/hello/
)
Array
(
    [hello] => world
    [foo] => bar
)
但建议我使用访问规则,从中我可以得到如下结果

Array
(
    [data] => test/abc/hello/
    [hello] => world
    [foo] => bar
)
有人能帮我从htaccess获取结果吗?这可能有效(未测试):

附加了标志QSA:QueryString

但我很保守,因为你用它来获取数据,喂,喂,这太贵了。在PHP中,您可以使用:

<?php
$data = $_SERVER["REQUEST_URI"];
$hello = $_GET["hello"];
$foo = $_GET["foo"];
?>

无需任何重写。

这可能有效(未测试):

附加了标志QSA:QueryString

但我很保守,因为你用它来获取数据,喂,喂,这太贵了。在PHP中,您可以使用:

<?php
$data = $_SERVER["REQUEST_URI"];
$hello = $_GET["hello"];
$foo = $_GET["foo"];
?>

无需任何重写