重写请求,保留参数并设置新参数
我正在尝试重写对索引页的请求,保留查询字符串参数并添加一个新参数。
示例:
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'
);
我识别请求,设置参数并重写到正确的页面。但我无法保留旧的查询字符串参数。
RewriteRule ^products(.*) index.php?page=products [NC,L]
// index.php
$_REQUEST = array(
'page' => 'products'
);
TIA
I am trying to rewrite the request to the index page, keeping the query string params and adding a new one.
Exemple:
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'
);
I identify the request, set a param and rewrite to the correct page. I cannot keep the old query string params though.
RewriteRule ^products(.*) index.php?page=products [NC,L]
// index.php
$_REQUEST = array(
'page' => 'products'
);
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[QSA]
标志将任何替换参数附加到现有集合中 - 例如,在第二个示例中使用[NC,QSA,L]
。如果这适合您,我可以请您检查我的答案是否已解决吗?
The
[QSA]
flag appends any substitution parameters to the existing set -- e.g. in your second example use[NC,QSA,L]
.If that suits you, may I ask you to check my answer as solved?