How to redirect URLs in Ghost using Nginx

Redirect URLs is now possible on Ghost uploading a JSON file redirects.json to the console since the version 1.9.0, but the recommended way is to use your web server to make redirects.

If you don't have access to your web server and you need more information, here is the official link:
https://docs.ghost.org/docs/redirects

For this tutorial we are going to use Nginx, I will assume you already have configured the web server, you only need to follow couple steps.

In the Nginx configuration, in the server section, you can add all the redirects that you want, I recommend to add the redirects at the end of the section.

For example, if you want to redirect an article from:
https://my-web.foo/my-old-url/ to https://my-web.foo/my-new-url/

Steps:

This is the only line of code that you need to add to yout configuration file:

server {
    . . .
    # ghost redirect
    rewrite ^/my-old-url/$ /my-new-url/ permanent;
    . . .
}

After editing the file, you will need to reload the Nginx server with this command:

sudo service nginx reload

The redirect should be working now.

Example

This is example in my blog, this url:
/how-to-create-a-bootable-windows-10-usb-on-macos-sierra-2/
Redirects to:
/how-to-create-a-bootable-windows-usb/