nginx rewrite url with dates in and change the format -


i'm moving blog on ghost , ok except around 50% of blog posts broken due date not being 0 padded i.e.

old site format: http://www.example.com/blog/index.cfm/2013/8/9/my-slug

new site format: http://www.example.com/2013/08/09/my-slug

removing /blog/index.cfm easy via

location /blog/index.cfm {     rewrite ^/blog/index.cfm(/.*)$ $1 last; } 

but cannot think of way 0 pad dates (and there around 700 posts).

put several rewrites.

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;     # other     rewrite ^/blog/index.cfm(/.*)$ $1 last; } 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -