将https://example.com重定向到https://www.example.com:Namecheap和Heroku [英] Redirect https://example.com to https://www.example.com: Namecheap and Heroku

查看:164
本文介绍了将https://example.com重定向到https://www.example.com:Namecheap和Heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将所有请求重定向到:

I'm trying to redirect all requests to:

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

https://www.example.com.我正在使用Heroku和Namecheap.

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

这是我的步骤:

  1. 在Heroku中,我将www.example.com添加到了我的域中,并启用了SSL.
  2. 在Namecheap上,我创建了一个CNAME记录,其中主机wwwwww.example.com.herokudns.com.
  3. 在Namecheap上,我用主机@https://www.example.com/创建了URL Redirect记录.
  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/.

通过这些步骤,只要我将http请求重定向到服务器端的https请求(例如,将http://www.example.com/重定向到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/).

我唯一不知道的事情是如何将https://example.com重定向到https://www.example.com.根据我的阅读,看来这是ALIAS记录可以完成的工作.不幸的是,Namecheap似乎没有这种类型的记录.

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.

是否可以使用Namecheap获得此行为,还是必须使用其他DNS提供程序?

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

推荐答案

对于仍然存在此问题的任何人,我都找到了Namecheap解决方案,用于将根域重定向到子域.

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

  1. 我将子域指向了我的网站位置(在这种情况下为Github页面)
  2. 我为@ host创建了一个CNAME记录,并将其值作为我的子域

这会将我的根域重定向到我的子域.

This redirects my root domain to my subdomain.

这篇关于将https://example.com重定向到https://www.example.com:Namecheap和Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆