Dynamic link 301 under the pagoda panel nginx jumps to pseudo-static configuration file modification

301 is generally when a new link appears after a page link is changed, and the old link becomes a 404, which is very unfavorable to the user experience. Therefore, it is recommended to jump the old link 301 to the new link and pass the weight to the past. It is especially important for the site to replace cms. The link rules are often different after cms is replaced, resulting in the loss of the weight of the old site

Generally, the modified 301 rule does not have a question mark, for example

rewrite ^/jingji(.*)$ https://www.kylunwen.com/list-6-1.html permanent;

The above is only suitable for static links

But for old link pages (or spiders used to grab dynamic link pages, but dynamic links don’t want him to participate in ranking) multi-parameters with question marks are not easy to use

You can only use the following method, which has only one parameter

if ($request_uri ~* "^/\?p=(\d+)$") {
          set $myarg1 $1;
          rewrite .* https://www.kylunwen.com/$myarg1.html? permanent;
}

Take two parameters like this

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;
      }

 

Guess you like

Origin blog.csdn.net/qq_41608099/article/details/106727792