本文介紹了使用 mod_rewrite 替換查詢(xún)字符串參數(shù)值的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我想映射這個(gè):
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.)
換句話說(shuō),只需更改查詢(xún)字符串中單個(gè)參數(shù)的值.我知道舊值是什么,所以我試圖匹配確切的文本 index.php?param1=value1
并將其替換為 index.php?param1=newvalue1
.我似乎無(wú)法找到有關(guān)如何使用 mod_rewrite 執(zhí)行此操作的任何示例.非常感謝任何幫助.
In other words, just change the value of a single parameter in the query string. I know what the old value is, so I am trying to match the exact text index.php?param1=value1
and replace it with index.php?param1=newvalue1
. I cannot seem to find any examples on how to do this using mod_rewrite. Any assistance greatly appreciated.
推薦答案
試試這個(gè)規(guī)則:
RewriteCond %{QUERY_STRING} ^(([^&]*&)*)param1=value1(&.*)?$
RewriteRule ^index.php$ /index.php?%1param1=newvalue1%3 [L,R=301]
這篇關(guān)于使用 mod_rewrite 替換查詢(xún)字符串參數(shù)值的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!