0

I just converted my blog from blogger to pelican. On blogger, posts used to be something like: http://blog.example.com/2014/09/title-slug.html, now my blog on pelican is http(s)://blog.exmaple.com/title-slug.html.

Now that I've moved from blogger to pelican (self-hosting), I want to rewrite URL types from blogger to the one I'm using on pelican.

I've never actually done regexp or nginx rewrite rules, so I'm lost as to how I should go about writing those rules. I've tried a few looking at some examples, but they aren't working. E.g:

location ^/([0-9]+)/([0-9]+)/([a-z0-9-]+)/\.html$ {
    rewrite ^(.*) /$1 permanent;
}
HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
Maverick
  • 3
  • 2

2 Answers2

0

Take it out of the location block, then this should work:

rewrite ^/\d+/\d+/([^/]+\.html)$ /$1 permanent;
Shane Madden
  • 114,520
  • 13
  • 181
  • 251
0

You forgot the regex operator : ~.

location ~ ^/\d+/\d+/([-\w]+)\.html$ {
    return 301 /$1.html;
}
Xavier Lucas
  • 13,095
  • 2
  • 44
  • 50