skip to Main Content

I am moving to a new domain and have set up 301 redirects on my ec2 instance.

Currently I have the following:

server {
   listen 80;
   server_name olddomain.co.uk;
   return 301 $scheme://www.newdomain.com$request_uri;
}

this works fine for www.olddomain.co.uk and olddomain.co.uk. However it does not work for https://www.olddomain.co.uk

I am wondering how I can make it so the redirect also works with https://www…

Thanks

2

Answers


  1. server {
    
        listen 80 default_server;
    
    
        server_name _;
    
    
        return 301 https://$host$request_uri;
    
    }
    
    Login or Signup to reply.
  2. Your server isn’t listening to https:// i.e. 443 port. Connection to https://www.olddomain.co.uk would simply be refused. Add proper ssl configurations to your nginx file and it should be fine.

    server {
       listen 80;
       listen 443 ssl;
       server_name olddomain.co.uk;
       return 301 $scheme://www.newdomain.com$request_uri;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search