andybeak
5/27/2016 - 11:34 AM

For blog post - Nginx redirection

For blog post - Nginx redirection

# redirects http traffic to https
server {
    listen 80;
    listen [::]:80;

    server_name mysite.co.uk www.mysite.co.uk;
    return 301 https://$server_name$request_uri;
}

# redirect non-www to www
server {
    listen 443;
    listen [::]:80;

    server_name mysite.co.uk;
    return 301 $scheme://www.mysite.co.uk$request_uri;
}