我想对此进行映射:

http://www.example.com/index.php?param1=value1&param2=value2&param3=value3 (etc. ad infinitum)


http://www.example.com/index.php?param1=newvalue1&param2=value2&param3=value3 (etc.)

换句话说,只需更改查询字符串中单个参数的值即可。我知道原来的值是什么,所以我尝试匹配确切的文本index.php?param1=value1并将其替换为index.php?param1=newvalue1。我似乎找不到使用mod_rewrite如何执行此操作的任何示例。任何帮助,不胜感激。

最佳答案

尝试以下规则:

RewriteCond %{QUERY_STRING} ^(([^&]*&)*)param1=value1(&.*)?$
RewriteRule ^index\.php$ /index.php?%1param1=newvalue1%3 [L,R=301]

10-05 20:19
查看更多