问题
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:
- In Heroku, I added
www.example.com
to my domains, and enabled SSL. - On Namecheap, I created a
CNAME
record with hostwww
towww.example.com.herokudns.com.
- On Namecheap, I created a
URL Redirect
record with host@
tohttps://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?
回答1:
For anyone that is still having this issue, I found a solution with Namecheap for redirecting the root domain to a subdomain.
- I pointed my subdomain to my website location (Github pages in this case)
- I created a CNAME record for @ host and made its value my subdomain
This redirects my root domain to my subdomain.
来源:https://stackoverflow.com/questions/43266066/redirect-https-example-com-to-https-www-example-com-namecheap-and-heroku