[英]htaccess url rewriting, query parameters are not available in script
I am using following rule to rewrite a url in directory style, 我正在使用以下规则以目录样式重写网址,
RewriteRule ^post/([0-9]+)$ post.php?pid=$1
by using this i am directing localhost/post.php?pid=3
to localhost/post/3
通过使用这个我将
localhost/post.php?pid=3
定向到localhost/post/3
but now I want to pass more parameters in default way like ?key=value
. 但是现在我想以默认方式传递更多参数,例如
?key=value
。
for example localhost/post/3?comment_id=23
but this key value pair is not available in script. 例如
localhost/post/3?comment_id=23
但是此键值对在脚本中不可用。 When I do echo $_GET['comment_id']
it's not echo'ing anything. 当我
echo $_GET['comment_id']
它没有回显任何内容。
How do I get it done. 我如何完成它。
You need to use QSA (query string append) flag. 您需要使用QSA(查询字符串追加)标志。 Change your rule to:
将规则更改为:
RewriteRule ^post/([0-9]+)$ post.php?pid=$1 [L,QSA]
QSA flag will append pid query parameter while preserving original query string in the URI thus you can do: QSA标志将在URI中保留原始查询字符串的同时追加pid查询参数,因此您可以执行以下操作:
$_GET['comment_id']
and also: 并且:
$_GET['pid']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.