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

1

15

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?

Avenge answered 6/4, 2017 at 21:28 Comment(4)
What is your web server? do you have access to a .htaccess file?Marlow
This is what I would like to figure out. @Avenge any luck on this in the past two years? Thank you!Rope
A related question/answer, which is for GitHub but it might also work for Heroku: https://mcmap.net/q/73814/-custom-domain-for-github-project-pagesStitt
Checkout this answer here https://mcmap.net/q/334985/-force-my-heroku-app-to-use-ssl-httpsCasting
C
3

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 e.g www.example.com 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.

Checky answered 1/9, 2019 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.