Ghost Blog Redirect Configuration for WordPress Migration

Table of Contents

In my earlier post Lighttpd url.redirect and changing WordPress permalink structure, I talk about the issue when permalink structure is changed.

New Issue

When migrating from WordPress to Ghost, the permalink structure is changed again, from

1
https://johnsiu.com/index.php/sample-post/

to

1
https://johnsiu.com/sample-post/

Solution

Ghost development team provided a perfect and simple solution in version 0.11.4, the redirects.json. The official document is here.

redirects.json need to be placed in <Ghost root>/content/data/.

The redirects.json for my site is as follow

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[
  {
    "permanent": true,
    "from":"^/index.php/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.*)$",
    "to":"/$1"
  },
  {
    "permanent": true,
    "from":"^/index.php/category/(.*)$",
    "to":"/tag/$1"
  },
  {
    "permanent": true,
    "from":"^/index.php/(.*)$",
    "to":"/$1"
  }
]

The above will take care of the following redirects:

Done!! ^.^

John Siu
Minimize the Effort, Maximize the Effect!
comments powered by Disqus