GitHub页面https/www重定向
如何获取 https://www.test.com 重定向到
How can I get https://www.test.com to redirect to https://test.com when using GitHub pages to host a static website?
我最近通过在我的DNS提供商(namecheap)上设置A记录来为我的静态站点启用TLS(由GitHub/Lets Encrypt提供).我还在GitHub存储库的设置中选择了强制HTTPS"选项,该选项可处理来自 http://test.com 的重定向请求到 https://test.com .我通过我的DNS提供程序配置了重定向,该重定向将 http://www.test.com 转发到 https://test.com ,但难题中缺少的一个就是转发 https://test.com 一个>.
I recently enabled TLS (provided by GitHub/Lets Encrypt) for my static site by setting A records at my DNS provider (namecheap). I've also chosen to "Enforce HTTPS" option in my GitHub repository's settings, which handles redirecting requests from http://test.com to https://test.com. I have a redirect configured through my DNS provider which forwards http://www.test.com to https://test.com, but the one missing piece of the puzzle is forwarding https://www.test.com to https://test.com.
关于此问题,GitHub说:如果您的域启用了HTTPS强制实施,则GitHub Pages的服务器将不会自动路由重定向.您必须使用域注册商配置www子域和根域重定向."
Regarding this issue, GitHub says, "If your domain has HTTPS enforcement enabled, GitHub Pages' servers will not automatically route redirects. You must configure www subdomain and root domain redirects with your domain registrar."
...,我的DNS提供商说:无法在帐户中为从 http://www.domain.tld (使用端口80)到 https://www.domain .tld (通过端口443工作)."
... and my DNS provider says, "It is not possible to set up a URL redirect in the account for the TCP port forwarding from http://www.domain.tld (uses port 80) to https://www.domain.tld (working via port 443)."
我似乎陷入了两个服务的无限循环中,说另一个服务应该提供此功能.
I seem to be caught in an infinite loop of the two services saying the other should provide this functionality.
对我有用的东西:
-
将您的自定义域更改为以
www.
为前缀,如下所示:
Change your custom domain to be prefixed with
www.
, like this:
保存设置,然后等待www.example.com解析并工作.
Save the settings and wait until www.example.com resolves and works.
删除www.
前缀并再次保存.
等待浏览器和DNS缓存失效.
Wait for browser and DNS caches to invalidate.
所有组合均应导致 https://example.com/,并且不会出现SSL错误.
All combinations should lead to https://example.com/ and no SSL error should appear.