我只是将我的博客转移到Ghost,一切都很好,除了我的博客帖子中约有50%因为日期没有被填零而被打破,即
旧网站格式: http://www.example.com/blog/index.cfm/2013/8/9/my-slug
新网站格式: http://www.example.com/2013/08/09/my-slug
通过
轻松删除/blog/index.cfmlocation /blog/index.cfm {
rewrite ^/blog/index.cfm(/.*)$ $1 last;
}
但是想不到零填充日期的方法(并且有大约700个帖子)。
答案 0 :(得分:3)
多次重写。
location /blog/index.cfm {
# 2013/1/1
rewrite ^/blog/index.cfm(/\d+)/(\d)/(\d)(/.*)?$ $1/0$2/0$3$4 last;
# 2013/1/11
rewrite ^/blog/index.cfm(/\d+)/(\d)/(\d\d)(/.*)?$ $1/0$2/$3$4 last;
# 2013/11/1
rewrite ^/blog/index.cfm(/\d+)/(\d\d)/(\d)(/.*)?$ $1/$2/0$3$4 last;
# all other
rewrite ^/blog/index.cfm(/.*)$ $1 last;
}