简体   繁体   中英

Nginx: Mapping WordPress URLs to new static website

I am currently moving my blog from a WordPress site that used the URL scheme:

http://www.domainname.com/<YEAR>/<MONTH>/<ARTICLE_SLUG> 

To a static blog site built with Nikola that uses the following URL scheme:

http://www.domainname.com/posts/<ARTICLE_SLUG> 

The original WordPress scheme had built a little bit of Google juice over the years and I would like keep harnessing that. I use Nginx as my web server. Is there a simple way for Nginx to map all the old URLs to the new URLs via configuration. I was thinking that the ngx_http_map_module Nginx Module is the most likely candidate, but I wanted to get a second opinion.

Should work. Just put a location block in your server config similar to this

location ~ "^/[\d]{4}/[\d]{2}/(.*)$"   {return 301 $scheme://$host/posts/$1;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM