301 redirect in nginx

A permanent server redirect is useful when you move domain, or when you want to redirect
users to the WWW-version

Example for nginx, add the following into /etc/nginx/conf.d/redirect.conf

server {
    server_name oldDomain.com;
    return 301 $scheme://www.newDomain.com$request_uri;
}