Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect https://example.com to https://www.example.com: Namecheap and Heroku

I'm trying to redirect all requests to:

https://example.com
http://www.example.com
http://example.com

to https://www.example.com. I'm using Heroku and Namecheap.

Here are my steps:

  1. In Heroku, I added www.example.com to my domains, and enabled SSL.
  2. On Namecheap, I created a CNAME record with host www to www.example.com.herokudns.com.
  3. On Namecheap, I created a URL Redirect record with host @ to https://www.example.com/.

With these steps, everything works well as long as I redirect http requests to https requests on the server side (e.g. redirect http://www.example.com/ to https://www.example.com/).

The only thing I can't figure out is how to redirect https://example.com to https://www.example.com. From what I've read, it looks like this is what an ALIAS record could accomplish. Unfortunately, Namecheap doesn't seem to have this type of record available.

Is it possible get this behavior using Namecheap, or do I have to use a different DNS provider?

like image 642
hetelek Avatar asked Apr 06 '17 21:04

hetelek


People also ask

How do I redirect http to namecheap?

Go to cPanel > Exclusive for Namecheap customers section > Namecheap SSL: 2. Next, click Installed via plugin and switch HTTPS Redirect toggle on. NOTE: HTTPS redirect feature is available if the SSL certificate was installed via the Namecheap SSL plugin only.

Can DNS redirect http to https?

No, you cannot redirect HTTP to HTTPS at the DNS level. This is something you have to configure on your web server (because it manages the protocol). If you don't have access to your web server, you will need to contact your web hosting provider.


1 Answers

For anyone that is still having this issue, I found a solution with Namecheap for redirecting the root domain to a subdomain.

  1. I pointed my subdomain to my website location (Github pages in this case)
  2. I created a CNAME record for @ host and made its value my subdomain

This redirects my root domain to my subdomain.

like image 169
ktbee Avatar answered Oct 03 '22 04:10

ktbee