0

I have an existing website for which I want to change the domain name. I will continue to use the same server and IP address, I only wish to change the domain. I am using nginx and Namecheap.

So far I have:

  • Purchased the new domain through namecheap
  • Created the A Record for @ and A Record for www for the new domain
  • Updated my existing nginx config to the new domain including a new lets encrypt ssl cert
  • Removed the old ssl cert from the server

The new domain is now working correctly. The old domain redirects correctly but only for non https. In other words, the following works correctly:

But it does not work when using https from the old site. I contacted namecheap and they said it is not possible to do via their web console. So I presume I have to do it manually somehow in nginx?

darkpool
  • 169
  • 1
  • 1
  • 6

1 Answers1

1

You need a server block like following for https redirect:

server {
    listen 443 ssl;
    server_name old.domain;
    ssl_certificate /path/to/old/certificate;
    ssl_certificate_key /path/to/old/key;

    return 301 https://new.domain;
}

This means that your server needs to be set as A record for your old domain, and you also need similar server block for http redirects.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58