Question

Setting up a 301 redirect with Nginx for my Ghost blog?

Hi there,

I done the one click Ghost install and this works fine.

Then I decided to move my blog: FROM: blog.club.in (ccTLD) TO: blog.club.com (gTLD)

Basically from a ccTLD to a gTLD.

How do I setup a 301 with Nginx to redirect all http and https traffic from my ccTLD to the .com?

Thanks!

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

server {

  listen 80
  listen 443;

  server_name blog.club.in;

  location / {
    return 301 https://blog.club.com$request_uri;
  }

}

Hi All, this is an old topic. But I am trying to setup a 301 permanent redirect on my Ubuntu 18.04, Ghost 3.0 DigitalOcean Site.

I tried modifying etc/nginx/nginx.conf with the following server settings:

server {
    . . .
    server_name diyzam.com www.diyzam.com;

    rewrite ^/ads.txt$ https://api.nitropay.com/v1/ads-676.txt permanent;
    . . .
}

But when i run nginx -t it says “server” directive not allowed. I suspect its related to the ghost installation. Based on what I read here, it seems I may need to be modifying different nginx.conf file/s. But which ones? And where?

In /var/www/ghost/system there is an nginx-root folder, but its empty. I tried adding the modified nginx.conf file there, but it does not seem to effect anything. I’m just guessing here now. Any help?

Thanks

you can set the config from <jasonjpeters> directly to your nginx.conf innerline to section http {} like

...

server {

  listen 80
  listen 443;

  server_name blog.club.in;

  location / {
    return 301 https://blog.club.com$request_uri;
  }

}

...
}

please know that “…” dots are your other config parameters

Hi Jason,

Thanks for your answer. I have a follow up question.

Which is the file to modify? (is it default) or the conf file pertaining to ccTLD (club.in)

I have screenshots that might help:

  1. This is etc/nginx/sites-available directory: https://i.imgur.com/OUF2UIR.png

  2. These are the conf files inside the ghost directory: https://i.imgur.com/gnKMKup.png

Thanks!