301一般是某個頁面鏈接改動后,出現新鏈接,舊鏈接變成404,十分不利於用戶體驗,因此建議把舊鏈接301跳轉到新鏈接上,傳遞權重過去,對網站更換cms尤其重要,往往更換cms后鏈接規則不同,導致老站權重丟失
一般修改的301規則都是沒有問號的,比如說
rewrite ^/jingji(.*)$ https://www.kylunwen.com/list-6-1.html permanent;
以上這種只適合靜態鏈接
但是對於舊鏈接頁面(或者蜘蛛老抓動態鏈接頁面,但是動態鏈接又不想讓他參與排名)有問號的多參數的就不好使了
只能用一下的方法,這是只有一個參數的
if ($request_uri ~* "^/\?p=(\d+)$") {
set $myarg1 $1;
rewrite .* https://www.kylunwen.com/$myarg1.html? permanent;
}
帶兩個參數可以這樣
if ($request_uri ~* "^/index.php\?moduleid=(\d+)&itemid=(\d+)$") {
set $myarg1 $1;
set $myarg2 $2;
rewrite .* https://www.kylunwen.com/$myarg1-0-$myarg2-1.html? permanent;
}
