记一次由wordpress迁移到jpress的nginx配置
博客由wordpress迁移到了jpress,原wordpress中有搜索引擎收录的url需要301到新的博客。经分析,主要需要处理的url规则如下:
文章url:
规则:/a/xxx -> /article/xxx
例如:https://www.miigua.com/a/275.html
分类url:
规则:/c/xxx -> /article/category/xxx
例如:https://www.miigua.com/c/jpress
子分类url:
规则:/c/xxx/xxx1 -> /article/category/xxx1
例如:https://www.miigua.com/c/jpress/jpress-theme
找到规则后在nginx中增加:
# /a/xxx.html -> /article/xxx.html
if ($request_uri ~* ^/a/([0-9]+).html$ ){
return 301 /article/$1.html;
}
# /a/xxx -> /article/xxx.html
if ($request_uri ~* ^/a/([0-9]+)$ ){
return 301 /article/$1.html;
}
# /c/xxx/xxx1 -> /article/category/xxx1.html
if ($request_uri ~* ^/c/(.*)/(.*)$ ){
return 301 /article/category/$2.html;
}
# /c/xxx -> /article/category/xxx.html
if ($request_uri ~* ^/c/(.*)$ ){
return 301 /article/category/$1.html;
}
测试,没问题,搞定
版权声明:
作者:Miigua
链接:https://www.miigua.com/article/9.html
来源:米瓜的博客
文章版权归作者所有,未经允许请勿转载。
全部评论