Redirects

How to add redirects to your Ghost install

Use Nginx or Apache if you can

If you have access to your web server, and can add your redirects there, we'd always recommend doing this instead, as it's more performant and standardised.
If you don't have access to your webserver, Ghost's redirects are the next best thing 🙂

You can define your own HTTP redirects for your Ghost blog. The redirects file is a JSON file and needs to be located in content/data/redirects.json.

Each entry in the redirects file has the following structure:

{
  "from": "regex" ,
  "to":  "/url",
  "permanent": true | false
}

Permanent redirects (301) can be defined with permanent: true, otherwise we use 302 redirects as the default configuration.

Example:

[
    {
        "from": "^/post/[0-9]+/([a-z0-9\\-]+)",
        "to": "/$1"
    },
    {
        "permanent": true,
        "from": "/my-old-blog-post/",
        "to": "/revamped-url/"
    },
    {
        "from": "^\\/what(\\/?)$",
        "to": "/what-does-god-say"
    },
    {
        "from": "^\\/search\\/label\\/([^\\%20]+)$",
        "to": "/tag/$1"
    },
    {
        "from": "^\\/topic\\/",
        "to": "/"
    },
    {
        "from": "^/resources\\/download(\\/?)$",
        "to": "/shubal-stearns"
    },
    {
        "from": "^\\/[0-9]{4}\\/[0-9]{2}\\/([a-z0-9\\-]+)(\\.html)?(\\/)?$",
        "to": "/$1"
    },
    {
        "from": "^/prefix/([a-z0-9\\-]+)?",
        "to": "/blog/$1"
    }
]

Then restart ghost for the changes to take affect.

ghost restart

Redirects

How to add redirects to your Ghost install