Mod rewrite 重写请求,保留参数并设置新参数
我试图将请求重写到索引页,保留查询字符串参数并添加一个新的参数 例如:Mod rewrite 重写请求,保留参数并设置新参数,mod-rewrite,Mod Rewrite,我试图将请求重写到索引页,保留查询字符串参数并添加一个新的参数 例如: Request: products/?limit=10&page=4&as=many¶ms=as&I=need Rewrite to: index.php?page=pages&limit=10&page=4&as=many¶ms=as&I=need // index.php $_REQUEST = array( 'page'
Request: products/?limit=10&page=4&as=many¶ms=as&I=need
Rewrite to: index.php?page=pages&limit=10&page=4&as=many¶ms=as&I=need
// index.php
$_REQUEST = array(
'page' => 'products'
'limit' => '10',
'page' => '4',
'as' => 'many'
'params' => 'as',
'I' => 'need'
);
我识别请求,设置参数并重写到正确的页面。但是我不能保留旧的查询字符串params
RewriteRule ^products(.*) index.php?page=products [NC,L]
// index.php
$_REQUEST = array(
'page' => 'products'
);
TIA该
[QSA]
标志将任何替换参数附加到现有集合中——例如,在第二个示例中,使用[NC,QSA,L]
如果您觉得合适,我可以请您检查我的答案是否已解决吗?这是一个基于
mod\u rewrite
的问题吗?您的php文件中是否有RewriteRule^products(.*)index.php?page=products[NC,L]
?[QSA]标志将任何替换参数附加到现有集合中--例如,在第二个示例中使用[NC,QSA,L]
@ThinkingMonkey对不起,我没有讲清楚。这在我的.htaccess中。php代码只是为了说明我得到的参数。@terryE非常感谢,你解决了这个问题。我所需要的只是一个QSA标志。我无法将这个问题标记为已解决。绿色的复选符号消失了!:-O