How to do SSL redirect?

My default subdomain is non-compos-mentis.netlify.app. I recently changed my custom domain from blog.asarkar.org to blog.asarkar.com. I’ve been trying to set up a redirect from the old domain to the new one, and have added a domain alias for blog.asarkar.org, as well as set up a CNAME record blog -> non-compos-mentis.netlify.app with my DNS provider. However, I keep getting a SSL certificate error when accessing https://blog.asarkar.org/.

Here’s a cURL output:

curl -v -L blog.asarkar.org
...
* Connected to blog.asarkar.org (x.x.x.x) port 80 (#0)

< HTTP/1.1 301 Moved Permanently
< Cache-Control: public, max-age=0, must-revalidate
...
< Location: https://blog.asarkar.org/
...
* Connected to blog.asarkar.org (x.x.x.x) port 443 (#1)
...
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=ca; L=San Francisco; O=Netlify, Inc; CN=*.netlify.com
*  start date: Jun 15 00:00:00 2020 GMT
*  expire date: Aug  3 12:00:00 2021 GMT
*  subjectAltName does not match blog.asarkar.org
* SSL: no alternative certificate subject name matches target host name 'blog.asarkar.org'
* Closing connection 1

Heya, @asarkar! Cheers for posting over here at Netlify Community :wink:!

Did you consider setting up a domain alias? In the UI, you can add the second domain and it’ll direct traffic to your primary domain automagically!

I’ve already set up a domain alias, and refreshed the certificate to pick up both domains. However, it doesn’t redirect, just present the site at the old domain. I’ve now deleted the domain alias, and set up a URL redirect with my DNS provider; waiting to see if that works.

Okay!

If that doesn’t work, you can add the site as a domain alias. Although I said this will happen automagically, you will need to create a small redirect rule:

1 Like

I’ve seen the redirect options too, but they are path based, not for the whole domain.

blog.domaintoredirect.com/* blog.newdomain.com:splat 301!

That’d redirect everything from the first URL to the second URL :smiley:

1 Like

The Domain-level redirects don’t do the redirect Redirect options | Netlify Docs

https://github.com/asarkar/non-compos-mentis/blob/master/netlify.toml

force = true finally did it along with How to do SSL redirect? - #7 by asarkar

1 Like