0

我对 htaccess rewrite_mode 有疑问。当我在这些规则中使用多个 $_GET 变量时,第一个变量获取作为第一个 $_GET 变量的名称文件。请帮我。

RewriteEngine on
RewriteBase   /ts/
RewriteRule     ^(.+)/$                  ts.php?a=$1 [C]
RewriteRule     ^(.*)/(.+)/$             ts.php?a=$1&b=$2 [C]
RewriteRule     ^(.*)/(.*)/(.+)/$        ts.php?a=$1&b=$2&c=$3 [C]
RewriteRule     ^(.*)/(.*)/(.*)/(.+)/$   ts.php?a=$1&b=$2&c=$3&d=$4 [C,L]

这是“localhost/ts/1/”的输出

Array ( [a] => 1 )

这是“localhost/ts/1/2/”的输出

Array ( [a] => ts.php [b] => 2 )

这是“localhost/ts/1/2/3/”的输出

Array ( [a] => ts.php [b] => 2 [c] => 3 )

这是“localhost/ts/1/2/3/4/5/6/”的输出

Array ( [a] => ts.php/2/3 [b] => 4 [c] => 5 [d] => 6 )
4

1 回答 1

1

我不会使用链标志,只是反转你的 RewriteRules,比如:

RewriteEngine on

RewriteBase   /ts/

RewriteRule     ^(.*)/(.*)/(.*)/(.+)/$   ts.php?a=$1&b=$2&c=$3&d=$4 [L]
RewriteRule     ^(.*)/(.*)/(.+)/$        ts.php?a=$1&b=$2&c=$3 [L]
RewriteRule     ^(.*)/(.+)/$             ts.php?a=$1&b=$2 [L]
RewriteRule     ^(.+)/$                  ts.php?a=$1 [L]
于 2013-06-20T11:31:36.457 回答