Ghost Blog Redirect Configuration for WordPress Migration

Permalink Structure Changed

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

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

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

to

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

[
    {
        "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!! ^.^