我想对此进行映射:
http://www.example.com/index.php?param1=value1¶m2=value2¶m3=value3 (etc. ad infinitum)
至
http://www.example.com/index.php?param1=newvalue1¶m2=value2¶m3=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]