Www to non-www on 3.1.1

Including this forum I inveled all the resources I found and followed the instructions I trusted, but I couldn’t redirect www-to-non-www.on Ghost 3.1.1-Digital Ocean. Could you help me?

Just for clarity, you want to redirect example.com to www.example.com?

I think like my blog www.dasnetzundich.de

Www to non-www

My setup for redirect:

server {
listen 80;
listen [::]:80;

server_name www.dasnetzundich.de;
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

location / {
    #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    #proxy_set_header X-Forwarded-Proto $scheme;
    #proxy_set_header X-Real-IP $remote_addr;
    #proxy_set_header Host $http_host;
    #proxy_pass http://127.0.0.1:2368;
    return 301 https://dasnetzundich.de$request_uri;
}

location ~ /.well-known {
    allow all;
}

client_max_body_size 50m;

}

You want to redirect www.dasnetzundich.de to dasnetzundich.de? If so, you need to make sure you actually have a server block for dasnetzundich.de and then you need a server block like the following

server {
  listen 80;

  server_name www.dasnetzundich.de;
  return 301 http://dasnetzundich.de$request_uri;
}

Yes, for me it works fine :slight_smile: