【问题标题】:GET parameters in htaccess url rewritinghtaccess url重写中的GET参数
【发布时间】:2013-01-09 03:44:52
【问题描述】:

我正在用 htaccess 重写一些 url。我有这个:

RewriteRule ^mesas$ http://www.myweb.net/piezas.php?pos=1 [L]
RewriteRule ^sillas$ http://www.myweb.net/piezas.php?pos=2 [L]
RewriteRule ^taburetes$ http://www.myweb.net/piezas.php?pos=3 [L]

这是有效的。如果我写网址http://www.myweb.net/mesas 我得到http://www.myweb.net/piezas.php?pos=1。

现在我想添加其他参数。例子: 我有这个http://www.myweb.net/mesas?pag=10 我想要这个:http://www.myweb.net/piezas.php?pos=1&pag=10

我正在尝试:

RewriteRule ^mesas?(.*)$ http://www.myweb.net/piezas.php?pos=1&$1 [L]

和

RewriteRule ^mesas$?(.*) http://www.myweb.net/piezas.php?pos=1&$1 [L]

但它不起作用。我做错了什么?

谢谢!

【问题讨论】:

  • “它不起作用”是什么意思?

标签: .htaccess mod-rewrite url-rewriting


【解决方案1】:

尝试添加标志 QSA,如下所示:

RewriteRule ^mesas$ http://www.myweb.net/piezas.php?pos=1 [L,QSA]
RewriteRule ^sillas$ http://www.myweb.net/piezas.php?pos=2 [L,QSA]
RewriteRule ^taburetes$ http://www.myweb.net/piezas.php?pos=3 [L,QSA]

它将追加传入的查询字符串到现有的。

【讨论】:

    猜你喜欢
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-12
    • 1970-01-01
    相关资源
    最近更新 更多