比如:
http://www.xxx.com/x/index.html
http://www.xxx.com/x/index.html?b1=y&b2=z&....
http://www.xxx.com/x/question.html
http://www.xxx.com/x/question.html?b1=y&b2=z&....
怎麼寫rewrite規則,把上面的轉換為下面的連結:(就是把a1這個參數的值改為問號後面參數傳入)
http://www.xxx.com/index.php?a1=x
http://www.xxx.com/index.php?a1=x&b1=y&c1=z&....
http://www.xxx.com/question.php?a1=x
http://www.xxx.com/question.php?a1=x&b1=y&c1=z&....
回複內容:
比如:
http://www.xxx.com/x/index.html
http://www.xxx.com/x/index.html?b1=y&b2=z&....
http://www.xxx.com/x/question.html
http://www.xxx.com/x/question.html?b1=y&b2=z&....
怎麼寫rewrite規則,把上面的轉換為下面的連結:(就是把a1這個參數的值改為問號後面參數傳入)
http://www.xxx.com/index.php?a1=x
http://www.xxx.com/index.php?a1=x&b1=y&c1=z&....
http://www.xxx.com/question.php?a1=x
http://www.xxx.com/question.php?a1=x&b1=y&c1=z&....
我寫一個index.html的規則,question.html的題主照著自己寫一下吧。
RewriteRule ^/x/index.html$ /index.php?a1=x [NC,L]
RewriteRule ^/x/index.html\?([^\/])+$ /index.php?a1=x&$1 [NC,L]
用正則匹配的反向引用,用這種方法其實a1,b1,c1三個參數都可以寫到RewriteRule裡的,前面偽靜態後邊是查詢字串是不是有點怪怪的。